_prom_page = {};
var num = 100;
var typeNum = 1;
var isyz=0;
var cfsq=0;
var jfsq=0;
var jflq=0;
var jlsp=0;
var jlsh=0;
var fview=0;
var fexport=0;
var fupseal=0;
var fsign=0;
var fupimg=0;
var flistdel=0;
var  zjl=0;

var jsondata = {
    "id": '',
    "spmId": '',
    "type": '',
    "fs_status": '',
    "stageId": ""
}
var button_array = null;
var layer, form, laydate, upload, uploadListIns, element, table;
var typeNum;
var jflq_content;
var _model;

layui.use(['form', 'laydate', 'layer', 'upload', 'element', 'table'], function () {
    laydate = layui.laydate;
    form = layui.form;
    upload = layui.upload;
    element = layui.element;
    table = layui.table;
    _prom_page = {
        _init: function (a, b) {
            this.typeNum = a;
            isyz=$("#isyz").val();
            cfsq=$("#cfsq").val();
            jfsq=$("#jfsq").val();
            jflq=$("#jflq").val();
            jlsp=$("#jlsp").val();
            jlsh=$("#jlsh").val();
            fview=$("#fview").val();
            fexport=$("#fexport").val();
            fupseal=$("#fupseal").val();
            fsign=$("#fsign").val();
            fupimg=$("#fupimg").val();
            flistdel=$("#flistdel").val();
            zjl=$("#zjl").val();
            jsondata.id = b.id;
            jsondata.spmId = b.spmId;
            jsondata.stageId = b.stageId;
            _prom_page.events.__init();
            _prom_page.events.uploadfjinit(0,"seal");
        },
        events: {
            __init: function () {
                 _model = getQueryString('type');
                //初始化 uplaod组件  上传按钮绑定
                _prom_page.events._init.uploadinit();
                // 分包tab title 点击事件绑定
                _prom_page.events._init.titleclickinit();
                //针对监理付款申请 初始化上传图片的事件
                _prom_page.events._init.imageUploadinit();
                // 付款记录
                _prom_page.events._init.hkRenderTable();
                // 初始化查看按钮事件
                $('.btn_vew').click(_prom_page.events.viewclick);
                //初始化监理内部审批事件
                $('.btn_jlnbsp').click(_prom_page.events.jlnbspclick);
                //初始化监理内部审核事件
                $('.btn_jlnbsh').click(_prom_page.events.jlnbshclick);
                //监发两签
                $('.btn_jflq').click(_prom_page.events.jflqclick);
                //监发三签
                $('.btn_jfsq').click(_prom_page.events.jfsqclick);
                //承发三签
                $('.btn_cfsq').click(_prom_page.events.cfsqclick);
                //盖章
                $('.btn_gz').click(_prom_page.events.gzclick);
                //签字
                $('.btn_dzsign').click(_prom_page.events.dzsignclick);
                //部门审核
                $('.btn_jldeptsh').click(_prom_page.events.deptcheckclick);

                //点击里程的时候，页面自动跳转到锚点：
                _prom_page.events._init.pageMoveInit();
            },
            _init: {
                pageMoveInit: function(){
                    var pageMove = localStorage.getItem("pageMove");
                    var noPageMove = localStorage.getItem("noPageMove");
                    console.log(pageMove);
                    console.log(noPageMove);
                    if(localStorage.getItem("pageMove") && localStorage.getItem("pageMove") == '1' &&
                        (!localStorage.getItem("noPageMove"))){
                        $("html,body").animate({scrollTop:$(".maodian").offset().top},200);
                        localStorage.removeItem("pageMove");
                    }
                    if(localStorage.getItem("noPageMove")){
                        localStorage.removeItem("noPageMove");
                    }
                },
                uploadinit: function () {
                    var loading;
                    var fileIndexarry=new Array();
                    uploadListIns = upload.render({
                        elem: '.img-upload',
                        url: '/supervisor/projectManager/addFile',
                        accept: 'file',
                        data: jsondata,
                        multiple: true,
                        auto: true,
                        choose: function (obj) {
                            var item = this.item;
                            var files = this.files = obj.pushFile();
                            //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                            obj.preview(function (index, file, result) {
                                fileIndexarry.push(index);
                            });

                        },
                        before: function () {
                            loading = layer.msg('提示：文件过大等候时间会长。正在上传。。', {icon: 16, shade: 0.3, time:0});
                            jsondata.type = this.type;
                            jsondata.fs_status = this.value;
                            if (this.filecount) {
                                jsondata.fileCount = this.filecount;
                            } else {
                                jsondata.fileCount = -1;
                            }
                            var bt = $(this.item).attr("bt-data");
                            // 如果页面没有定义样式
                            if (bt == undefined || bt == "" || bt == null) {
                                bt = "[]";
                            }
                            button_array = eval('(' + bt + ')');
                            if (this.lx == '1') {
                                var fbid = $(this.item).parents(".layui-tab-content").eq(0).prev().find(".layui-this").attr("value");
                                jsondata.fbId = fbid;
                            } else if (this.lx == '2') {
                                jsondata.fbId = this.fbid;
                            } else {
                                jsondata.fbId = "";
                            }
                        },
                        done: function (res, index, upload) {
                            for(var x in this.files){
                                if(x==index){
                                    delete this.files[index]; //删除对应的文
                                }
                            }
                            var lengfile=0;
                            for(var i in this.files){
                                lengfile++;
                            }
                            if(lengfile==0){
                                layer.close(loading);
                            }
                            if (res.flag) {
                                var data = res.data;
                                var id = data.id;
                                var filename = data.filename;
                                var wj_status = data.wj_status;// 文件状态
                                var lc_status = data.lc_status;// 里程状态
                                var jd_status = data.jd_status;// 阶段状态
                                var bgreason = data.bgreason;// 变更处理 变更原因
                                var item = this.item;
                                // 用来绑定图片上传事件，每次绑定的num 都不同（用来解决绑定上传事件失效问题）
                                num = num - 1;

                                if (button_array.indexOf("sc_image") > 0) {
                                    var li_str = '<li class=\"clearfix\"><div class="clearfix"><input type=\"checkbox\" class=\"fl\"  title=\"jian\"  value=' + id + '><span class=\"fl ml10\">' + filename + '</span>';
                                } else {
                                    var li_str = '<li class=\"clearfix\"><input type=\"checkbox\" class=\"fl\"  title=\"jian\"  value=' + id + '><span class=\"fl ml10\">' + filename + '</span>';
                                }
                                if(button_array.indexOf("upfj")>0){
                                    var li_str = '<li class=\"clearfix\"><div class="clearfix"><input type=\"checkbox\" class=\"fl\"  title=\"jian\"  value=' + id + '><span class=\"fl ml10\">' + filename + '</span>';
                                }
                                if (button_array.length > 0) {
                                    for (j = button_array.length - 1; j > -1; j--) {
                                        if (button_array[j] == 'c'  && fview=='1' ) {// 查看按鈕
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_view" onclick="_prom_page.events.viewclick(this)" >查看</button>';
                                        } else if (button_array[j] == 'd' && fexport=='1') {//导出
                                            li_str = li_str + '<button type="button" class="fr mt15 bgnone ml20" onclick="_prom_page.events.exportFile(this)">导出</button>'
                                        } else if (button_array[j] == 'q' && fsign=='1') {// 签字
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_gz"onclick="_prom_page.events.gzclick(this)">签字</button>';
                                        }else if (button_array[j] == 'img_in'  && fupimg=="1") {// 插入图片
                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone" tag="PO_CIMG" onclick="_prom_page.events.imgtoword(this)">插入图片</button>';
                                        }else if (button_array[j] == 'g' && fupseal=='1') {// 盖章
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_gz" onclick="_prom_page.events.gzclick(this)" >盖章</button>';
                                        } else if (button_array[j] == 'sp' && jlsp=="1") {// 内部审批
                                            //完成按钮至灰色
                                            if(jsondata.fbId  &&  jsondata.type!="038" &&  jsondata.type!="039" &&  jsondata.type!="042"  &&  jsondata.type!="043" &&  jsondata.type!="044"  &&  jsondata.type!="045"  ){
                                                $("#div_fb_"+jsondata.type).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }else{
                                                $(item).parents("div").eq(0).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jlnbsp" onclick="_prom_page.events.jlnbspclick(this)" >审批</button>';
                                        } else if (button_array[j] == 'sh' && jlsh=="1") {// 内部审核
                                            //完成按钮至灰色
                                            if(jsondata.fbId  &&  jsondata.type!="038" &&  jsondata.type!="039" &&  jsondata.type!="042"  &&  jsondata.type!="043" &&  jsondata.type!="044"  &&  jsondata.type!="045"  ){
                                                $("#div_fb_"+jsondata.type).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }else{
                                                $(item).parents("div").eq(0).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jlnbsh" onclick="_prom_page.events.jlnbshclick(this)" >审核</button>';
                                        } else if (button_array[j] == 'jf3' && jfsq=="1") {// 监发三签承发三签
                                            //完成按钮至灰色
                                            if(jsondata.fbId  &&  jsondata.type!="038" &&  jsondata.type!="039" &&  jsondata.type!="042"  &&  jsondata.type!="043" &&  jsondata.type!="044"  &&  jsondata.type!="045"  ){
                                                //$("#div_fb_"+jsondata.type).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }else{
                                              //  $(item).parents("div").eq(0).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }
                                            if (button_array.indexOf("sp") < 0 && button_array.indexOf("sh") < 0) {
                                                //一开始上传的时候含有这两个按钮 不显示这个
                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jfsq"   onclick="_prom_page.events.jfsqclick(this)" >监发三签</button>';
                                               // 不含有内部流程的  完成按钮可以点击  20210810 修改
                                                $(item).parents("div").eq(0).find(".btn_finish").removeClass("layui-btn-disabled");

                                            }
                                        } else if (button_array[j] == 'cf3'  ) {// 承发三签
                                            //完成按钮至灰色
                                           if(jsondata.fbId  &&  jsondata.type!="038" &&  jsondata.type!="039" &&  jsondata.type!="042"  &&  jsondata.type!="043" &&  jsondata.type!="044"  &&  jsondata.type!="045"  ){
                                               //$("#div_fb_"+jsondata.type).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }else{
                                               // $(item).parents("div").eq(0).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }
                                            if(cfsq=="1"){
                                                if (button_array.indexOf("sp") < 0 && button_array.indexOf("sh") < 0) {
                                                    li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_cfsq"   onclick="_prom_page.events.cfsqclick(this)" >承发三签</button>';
                                                    $(item).parents("div").eq(0).find(".btn_finish").removeClass("layui-btn-disabled");
                                                }
                                            }

                                        } else if (button_array[j] == 'jf2'  && jflq=='1') {// 监发两签
                                            //完成按钮至灰色
                                            if(jsondata.fbId  &&  jsondata.type!="038" &&  jsondata.type!="039" &&  jsondata.type!="042"  &&  jsondata.type!="043" &&  jsondata.type!="044"  &&  jsondata.type!="045"  ){
                                              //  $("#div_fb_"+jsondata.type).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }else{
                                               // $(item).parents("div").eq(0).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            }
                                            if (button_array.indexOf("sp") < 0 && button_array.indexOf("sh") < 0) {
                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jflq"   onclick="_prom_page.events.jflqclick(this)" >监发两签</button>';
                                                $(item).parents("div").eq(0).find(".btn_finish").removeClass("layui-btn-disabled");
                                            }
                                        } else if (button_array[j] == 'sc_image'  && fupimg=="1") {// 上传图片
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone upImage tab' + num + '"  onclick="_prom_page.events.scImage(this)">上传图片</button>';
                                        } else if (button_array[j] == 'qr_uplaod' && fupimg=="1") {// 确认上传
                                            li_str = li_str + '<button type="button"  style="display: none;" class="fr ml20 mt15 bgnone qr_uplaod  imageAction' + num + '"  onclick="_prom_page.events.comfirmScImage(this)" >确认上传</button>';
                                        } else if (button_array[j] == 'pl_delete' && fupimg=="1") {// 批量删除
                                            li_str = li_str + '<button type="button" style="display: none;"  class="fr ml20 mt15 bgnone pl_delete" onclick="_prom_page.events.plDeleteImage(this)"  >删除图片</button>';
                                        }else if(button_array[j] == 'upfj'){
                                            li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upfj tabup' + num + '""  >上传附件</button>';
                                        }else if(button_array[j] == 'upseal'){
                                            /*业主单位签章上传*/
                                            li_str = li_str + '<button type="button"   class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                        }else if(button_array[j] == 'addspjl'){
                                                li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone  addspjl"   onclick="_prom_page.events.addspjl(this)" >报审表</button>';
                                        }else if(button_array[j] == 'deptcheck'){
                                            $(item).parents("div").eq(0).find(".btn_finish").addClass("layui-btn-disabled").attr("disabled",true);
                                            li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone  addspjl"   onclick="_prom_page.events.deptcheckclick(this)" >部门审核</button>';
                                        }else if(button_array[j] == 'pl_delete_image'){
                                            /*批量删除图片*/
                                                li_str = li_str + '<button type="button"   class="fr ml20 mt15 bgnone btn_deletepic"    onclick="_prom_page.events.delpicPt(\'table'+id+'\')">删除附件</button>';
                                        }
                                    }
                                } else {// 追加默认样式
                                    if(fexport=='1'){
                                        li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone"  onclick="_prom_page.events.exportFile(this)">导出</button>';
                                    }
                                    if(fview=='1'){
                                        li_str = li_str + '<button type="button" class="fr mt15 bgnone ml20 btn_view" onclick="_prom_page.events.viewclick(this)">查看</button>';
                                    }


                                }
                                if (button_array.indexOf("sc_image") > 0) {
                                    if (jsondata.type == '109' || jsondata.type == '108' || jsondata.type == '087' || jsondata.type == '088') {
                                        //监理付款申请
                                        /*   li_str = li_str + '</div><div  style="border: 1px solid rgb(238, 238, 238); float:left;display: inline-block;width: 1000px;"><table id="table' + id + '" style="height: 300px;" class="layui-hide" lay-filter="table' + id + '"></table></div><div style="clear:both;"></div>';*/
                                        li_str = li_str + '</div><div  style="position:relative;float: left; border: 1px solid #EEEEEE;height: 300px;width: 98%; overflow-y: scroll;display: none"><label class="fl"style="margin-top: 15px;" ><div class="layui-upload-list yldemo"></div><div  style="clear: both;"></div></div><div  style="border: 1px solid rgb(238, 238, 238); float:left;display: inline-block;width: 98%;"><table id="table' + id + '" style="height: 300px;" class="layui-hide" lay-filter="table' + id + '"></table></div><div style="clear:both;"></div>';
                                    } else {
                                        li_str = li_str + '</div><div  style="position:relative;float: left; border: 1px solid #EEEEEE;height: 300px;width: 98%; overflow-y: scroll;display: none"><label class="fl"style="margin-top: 15px;" ><!--<span class="red">*</span>请填写部位</label>--><input type="text" placeholder="请填写部位"  autocomplete="off" style="margin-left: 12px;width: 400px;" name="positionName"   class="fl" value=""><div  style="clear: both;"></div><div class="layui-upload-list yldemo"></div><div  style="clear: both;"></div></div><div  style="border: 1px solid rgb(238, 238, 238); float:left;display: inline-block;width: 98%;"><table id="table' + id + '" style="height: 300px;" class="layui-hide" lay-filter="table' + id + '"></table></div><div style="clear:both;"></div>';
                                    }

                                }
                                if (button_array.indexOf("upfj") > 0) {
                                    li_str = li_str + '</div><div  style="position:relative;float: left; border: 1px solid #EEEEEE;height: 300px;width: 98%; overflow-y: scroll;display: none"><label class="fl"style="margin-top: 15px;" ><div class="layui-upload-list yldemo"></div><div  style="clear: both;"></div></div><div  style="border: 1px solid rgb(238, 238, 238); float:left;display: inline-block;width: 98%;"><table id="table' + id + '" style="height: 300px;" class="layui-hide" lay-filter="table' + id + '"></table></div><div style="clear:both;"></div>';
                                }
                                li_str = li_str + "</li>";
                                $(item).parent().parent().parent().next().append(li_str);
                                // 上传图片按钮添加上传监听事件
                                if (button_array != null) {
                                    if (button_array.indexOf("sc_image") > 0) {// 给上传图片按钮绑定 事件
                                        var jsonimagedata = {
                                            "id": jsondata.id,
                                            "spmId": jsondata.spmId,
                                            "stageId": jsondata.stageId,
                                            "fbId": jsondata.fbId,
                                            "parentId": "",
                                            "positionName": "",
                                            "uploadType": "002"
                                        }
                                        jsonimagedata.parentId = id;
                                        jsonimagedata.type = jsondata.type;
                                        _prom_page.events.inituploadImage(num, jsonimagedata, "filelist");
                                    }
                                    if (button_array.indexOf("upfj") > 0) {// 给上传附件的按钮绑定事件
                                        var jsonimagedata = {
                                            "id": jsondata.id,
                                            "spmId": jsondata.spmId,
                                            "stageId": jsondata.stageId,
                                            "fbId": jsondata.fbId,
                                            "parentId": "",
                                            "uploadType": "003"
                                        }
                                        // 003 shang
                                        jsonimagedata.parentId = id;
                                        jsonimagedata.type = jsondata.type;
                                        _prom_page.events.uploadfjinit(num);
                                    }
                                    if (button_array.indexOf("upseal") > 0) {// 给上传图片按钮绑定事件
                                        var jsonimagedata = {
                                            "id": jsondata.id,
                                            "spmId": jsondata.spmId,
                                            "stageId": jsondata.stageId,
                                            "fbId": jsondata.fbId,
                                            "parentId": "",
                                            "positionName": "",
                                            "uploadType": "003"
                                        }
                                        jsonimagedata.parentId = id;
                                        jsonimagedata.type = jsondata.type;
                                        _prom_page.events.uploadfjinit(num,'seal');
                                    }
                                }
                                // 控制本条文件类型的变换
                                if (wj_status == '1') {
                                    if (jsondata.fbId != undefined && jsondata.fbId != "") {// 分包的情况 样式处理
                                        // 到货验收
                                        if("038"==jsondata.type || "039"==jsondata.type || "042"==jsondata.type || "043"==jsondata.type || "044"==jsondata.type || "045"==jsondata.type){
                                            $("#div_fb_"+jsondata.type+"_" + jsondata.fbId).find("img").attr("src", "/plugin/common/images/16@2x.png");
                                        }else{
                                            $("#div_fb_" + jsondata.type).find("img").attr("src", "/plugin/common/images/16@2x.png");
                                        }

                                    } else {
                                        // 修改文件类型状态图标为 进行中
                                        $(item).parent().parent().prev().find("img").attr("src", "/plugin/common/images/16@2x.png");
                                    }
                                }
                                // 更新分包Id 到货验收里程
                                if(jsondata.type=="038"  || jsondata.type=="039" || jsondata.type=="042" || jsondata.type=="043" || jsondata.type=="044"){
                                    $(item).parents(".layui-tab-content").prev().find(".layui-this").find("img").attr("src", "/plugin/common/images/16@2x.png");
                                }
                                // 控制里程状态的变换
                                if (lc_status == '1') {
                                    // 修改里程状态图标为 进行中
                                    $("#lc_img_left").find("img").attr("src", "/plugin/common/images/16@2x.png");
                                    //修改左侧标题 里程状态
                                    $("#lc" + jsondata.spmId).attr("src", "/plugin/common/images/16@2x.png");
                                }
                                if (jd_status == '1') {
                                    // 修改阶段状态为进行中
                                    $("#jd" + jsondata.stageId).attr("src", "/plugin/common/images/16@2x.png");
                                }
                                //针对工程款支付  弹框填写支付次数和金额
                                if (jsondata.type == '108' || jsondata.type == '087') {
                                    //承建付款申请  监理付款申请
                                    _prom_page.events.openZfcs(id);
                                }
                                /*预案提示 变更处理*/
                                if(jsondata.type=="093"){
                                    if(bgreason){
                                        _prom_page.events.getProgram(bgreason);
                                    }
                                }

                            } else {
                                layer.msg("上传失败！" + res.msg, {icon: 2});
                            }
                        },
                        error: function (index, upload) {
                            layer.msg("上传失败！");
                        }
                    });

                },
                // 点击事件班绑定
                titleclickinit: function () {
                    $('.layui-tab-title li').on('click', function (i, v) {
                        var that = $(this);
                        var fbid = that.attr("value");
                        var index = that.attr("lay-index");
                        var laydata, content;
                        if (that.attr("lay-data")) {
                            laydata = eval('(' + that.attr("lay-data") + ')');
                            content = $(this);
                        } else {
                            laydata = eval('(' + $(this).parent().next().find(".fl:eq(0)").attr("lay-data") + ')');
                            content = $(this).parent().next();
                        }
                        _prom_page.events.clickChange(i, fbid, index, laydata, content)
                    });
                },
                imageUploadinit: function () {
                    //针对监理付款申请 页面加载完成给元素绑定事件
                    var datajson = {
                        "id": jsondata.id,
                        "spmId": jsondata.spmId,
                        "stageId": jsondata.stageId,
                        "fbId": jsondata.fbId ? jsondata.fbId : "",
                        "parentId": "",
                        "uploadType": "002"
                    }
                    var loading;
                    uploadListIns=upload.render({
                        elem: '.tabUploadImageZf',
                        url: '/supervisor/projectManager/addFile',//改成您自己的上传接口
                        multiple: true,
                        auto: false,
                        data: datajson,
                        bindAction: '.imageActionUploadImageZf',
                        choose: function (obj) {

                            var item = this.item;
                            // 上传区域显示
                            $(item).parent().parent().next().css("display", "block");
                            //确认上传按钮显示
                            $(item).parent().parent().find(".qr_uplaod").css("display", "block");
                            //批量删除按钮显示
                            $(item).parent().parent().find(".pl_delete").css("display", "block");
                            var files = this.files = obj.pushFile();
                            //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                            obj.preview(function (index, file, result) {
                                $(item).parent().parent().next().find(".yldemo").append('<div class="main"  style="position:relative;float: left; margin-left: 8px;"><div class="img"><img   style="width: 200px;height: 200px;margin: 5px;5px;" src="' + result + '" alt="' + file.name + '" class="layui-upload-img"></div> <div class="checkbox"  style="position:absolute;top:0;right:0;z-index:1000"><input id="box"  value="' + index + '" type="checkbox" name="box"></div><div class="fdImage"  style="position:absolute;bottom:0;right:0;z-index:1000"><img  style="width: 30px;height: 30px;float:right;" src="/plugin/common/images/big.png" onclick="_prom_page.events.imageEnlarge(this)"</div> ');
                                $('.pl_delete').on('click', function () {
                                    $(this).parent().next().find(".yldemo [type=checkbox]:checked").each(function (i, v) {
                                        var v_index = $(v).attr("value");
                                        delete files[v_index]; //删除对应的文件
                                        $(v).parent().parent().remove();
                                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                                    });
                                });
                            });


                        },
                        before: function (obj) {
                            loading = layer.msg('正在上传', {icon: 16, shade: 0.3, time:0});
                            var item = this.item;
                            // 获取文件序号
                            var index_wj = $(item).parents("li").eq(0).index();
                            // 获取文件id
                            datajson.parentId = $(item).parent().parent().find("[type=checkbox]").attr("value");
                            //获取文件类型
                            var laydata = $(this.item).parents("ul").eq(0).prev().find("label").find("button").attr("lay-data");
                            var type = eval('(' + laydata + ')').type;
                            datajson.type = type;
                            datajson.positionName = index_wj + 1;

                        },
                        done: function (res, index, upload) {
                            layer.close(loading);
                            if (!res.flag) {
                                layer.msg("上传失败！" + res.msg, {icon: 2});
                            }
                            var item = this.item;
                            $(item).parent().parent().next().find(".main").remove();
                            // 删除队列中的文件
                            delete this.files[index];
                            // 隐藏上传div
                            $(item).parent().parent().next().css("display", "none");
                            // 隐藏確定上传按钮
                            $(item).parent().parent().find(".qr_uplaod").css("display", "none");
                            // 隐藏批量删除按钮
                            $(item).parent().parent().find(".pl_delete").css("display", "none");
                            // 加载图片列表
                            var tablelist = "table" + datajson.parentId;
                            _prom_page.events.inittableImage(datajson, tablelist);


                        },
                        error: function (index, upload) {
                            layer.msg("文件上传失败", {icon: 2})
                        }
                    });
                    // 初始化列表
                    $(".tabUploadImageZf").each(function (i, v) {
                        var laydata = $(v).parents("ul").eq(0).prev().find("label").find("button").attr("lay-data");
                        var type = eval('(' + laydata + ')').type;
                        var v_id = $(v).parent().parent().find("[type=checkbox]").attr("value");
                        datajson.parentId = v_id;
                        datajson.type = type;
                        var tablelist = "table" + v_id;
                        _prom_page.events.inittableImage(datajson, tablelist);
                    });

                },
                hkRenderTable: function () {
                    layui.use(['table'], function () {
                        table = layui.table;
                        table.render({
                            elem: '#huikuan',
                            id: 'huikuan',
                            cellMinWidth: 80,
                            url:"gerRecordListHk?id="+jsondata.id,
                            height: '500',
                            cols: [[
                                {align: 'center', title: '操作', width: 100,templet:function(d){
                                        $("#payId1").val();
                                        return"<a href=\"javascript:void(0);\"  onclick=\"zxkzfFrom(\'"+d.payId+"\')\"> 编辑</a>" +
                                            "<a href=\"javascript:void(0);\"  onclick=\"jlkzfDel(\'"+d.payId +","+d.zfMoney+"\')\"> 删除</a>";
                                    }},
                                {field: 'sppNo',align: 'center',title: '付款次数',sort: false,width: '15%'},
                                {field: 'payId', align: 'center', title: '付款节点',sort: false, minWidth: 120, hide: true},
                                {field: 'sppNode', align: 'center', title: '支付节点/支付时间', sort: false,minWidth: 200, templet:function(d){
                                        if(d.payDate == ""||d.payDate == null){
                                            return d.badtName;
                                        }else{
                                            return d.payDate;
                                        }
                                    }},
                                {field: 'sppPersent',align: 'center',title: '付款比例',sort: false,width: 95,},
                                {field: 'zfMoney',align: 'center',title: '支付金额(元)',sort: false,width: 200},
                                {field: 'fpMoney',align: 'center',title: '开票金额(元)',sort: false,width: 200},
                                {field: 'createDate',align: 'center',title: '申请支付时间',sort: false,width: 200},
                                {field: 'isArrival',align: 'center',title: '到账占比',sort: false,width: 200},
                                {field: 'arrivalDate',align: 'center',title: '到账时间',sort: false,width: 210,templet:function(d){
                                        if(d.arrivalDate != "" && d.arrivalDate != null){
                                            var str = "";
                                            var arr = d.arrivalDate.split(",");
                                            for(var x = 0;x<arr.length;x++){
                                                var money = arr[x];
                                                if(arr.length == 1){
                                                    str =  "<div>首次付款时间:"+money+"</div>";
                                                }else{
                                                    var alb = NumberToChinese(x+1);
                                                    if(x==0){
                                                        str =  "<div>首次付款时间:"+money+"</div>";
                                                    }else if(x != arr.length-1){

                                                        str +="<div>第"+alb+"次付款时间:"+money+"</div>";
                                                    }else{
                                                        str +="<div>第"+alb+"次付款时间:"+money+"</div>";
                                                    }
                                                }
                                            }
                                            return str;
                                        }else{
                                            return "";
                                        }
                                    }},
                                {field: 'arrivalMoney',align: 'center',title: '到账金额(元)',sort: false,width: 200,templet:function(d){
                                        if(d.arrivalMoney != "" && d.arrivalMoney != null){
                                            var str = "";
                                            var arr = d.arrivalMoney.split(",");
                                            for(var x = 0;x<arr.length;x++){
                                                var money = arr[x];
                                                if(arr.length == 1){
                                                    str =  "<div>首次付款金额:"+money+"</div>";
                                                }else{
                                                    var alb = NumberToChinese(x+1);
                                                    if(x==0){
                                                        str =  "<div>首次付款金额:"+money+"</div>";
                                                    }else if(x != arr.length-1){

                                                        str +="<div>第"+alb+"次付款金额:"+money+"</div>";
                                                    }else{
                                                        str +="<div>第"+alb+"次付款金额:"+money+"</div>";
                                                    }
                                                }
                                            }
                                            return str;
                                        }else{
                                            return "";
                                        }
                                    }}

                            ]],
                            done: function (res, curr, count) {//动态监听表头高度变化，冻结行跟着改变高度
                                // $(".layui-table-header  tr").resize(function () {
                                //     $(".layui-table-header  tr").each(function (index, val) {
                                //         $($(".layui-table-fixed .layui-table-header table tr")[index]).height($(val).height());
                                //     });
                                // });
                                // //初始化高度，使得冻结行表头高度一致
                                // $(".layui-table-header  tr").each(function (index, val) {
                                //     $($(".layui-table-fixed .layui-table-header table tr")[index]).height($(val).height());
                                // });
                                // //动态监听表体高度变化，冻结行跟着改变高度
                                // $(".layui-table-body  tr").resize(function () {
                                //     $(".layui-table-body  tr").each(function (index, val) {
                                //         $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                                //     });
                                // });
                                // //初始化高度，使得冻结行表体高度一致
                                // $(".layui-table-body  tr").each(function (index, val) {
                                //     $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                                // });

                            }
                        });
                    });
                }
            },
            uploadfjinit: function (num,uptype) {
                //针对工程变更单  附件上传处理
                var datajson = {
                    "id": jsondata.id,
                    "spmId": jsondata.spmId,
                    "stageId": jsondata.stageId,
                    "fbId": jsondata.fbId ? jsondata.fbId : "",
                    "parentId": "",
                    "uploadType": "003"
                }
                var ismu=true;
                var isauto=true;
                var elemclass='.tabup'+num;
                var url="";
                if(uptype=='seal'){
                    datajson.uploadType='004';
                    elemclass='.tabsealup'+num;
                    url='/supervisor/projectManager/addFileFj';
                    ismu=false;
                }else{
                    url= '/supervisor/projectManager/addFile';
                    datajson.uploadType="002";
                }
                var loading;
                upload.render({
                    elem: elemclass,
                    url: url,
                    multiple: ismu,
                    accept: 'file',
                    auto: isauto,
                    data: datajson,
                    before: function (obj) {
                        loading = layer.msg('正在上传', {icon: 16, shade: 0.3, time:0});
                        var item = this.item;
                        var  lay_data=$(item).parent().parent().parent().prev().find("label").find("button").attr("lay-data");
                        if(uptype=='seal'){
                            datajson.type ="113";
                            /**/
                        }else{
                            var type = eval('(' + lay_data + ')').type;
                            datajson.type =type;
                            var fbid = $(this.item).parents(".layui-tab-content").eq(0).prev().find(".layui-this").attr("value");
                            datajson.fbId = fbid;
                        }
                        datajson.parentId = $(item).parent().find("[type=checkbox]").attr("value");
                    },
                    done: function (res, index, upload) {
                        layer.close(loading);
                        var  flag=res.flag;
                        if(flag){
                            var  url=res.data;
                            // 加载附件列表
                            if((uptype=='seal')){
                                layer.msg("图片上传成功,正在操作签章", {icon: 1})
                                setTimeout(function () {
                                    POBrowser.openWindowModeless('/sys/office/openword?ft=11&fid=' + datajson.parentId, 'width=1200px;height=800px;', '{}')
                                }, 3000);
                            }else{
                                var tablelist = "table" + datajson.parentId;
                                _prom_page.events.inittableImage(datajson, tablelist)
                            }
                        }else{
                            layer.msg("文件上传失败", {icon: 2})
                        }


                    },
                    error: function (index, upload) {
                        layer.msg("文件上传失败", {icon: 2})
                    }
                });
        },
            formatdate: function (datetime, fmt) {
                if (parseInt(datetime) == datetime) {
                    if (datetime.length == 10) {
                        datetime = parseInt(datetime) * 1000;
                    } else if (datetime.length == 13) {
                        datetime = parseInt(datetime);
                    }
                }
                datetime = new Date(datetime);
                var o = {
                    "M+": datetime.getMonth() + 1,                 //月份
                    "d+": datetime.getDate(),                    //日
                    "h+": datetime.getHours(),                   //小时
                    "m+": datetime.getMinutes(),                 //分
                    "s+": datetime.getSeconds(),                 //秒
                    "q+": Math.floor((datetime.getMonth() + 3) / 3), //季度
                    "S": datetime.getMilliseconds()             //毫秒
                };
                if (/(y+)/.test(fmt))
                    fmt = fmt.replace(RegExp.$1, (datetime.getFullYear() + "").substr(4 - RegExp.$1.length));
                for (var k in o)
                    if (new RegExp("(" + k + ")").test(fmt))
                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                return fmt;

            },
            clickDelete: function (object) {
                var checkbox = $(object).parent().parent().next().find("input:checked");
                if (checkbox.length == 0) {
                    layer.msg("请选择文件", {icon: 2});
                    return;
                }
                //只有总监理工程师 完成后可以删除
                if(zjl!="1"){
                    //点击完成后不能删除
                    var scr=$(object).parent().prev().find("img").attr("src");
                    if(scr){
                        if(scr.indexOf("15@2x.png")>0){
                            layer.msg("完成后,不允许删除", {icon: 2});
                            return;
                        }
                    }else{
                        var scr= $(object).parents(".layui-tab").eq(0).prev().find("div").eq(0).find("img").attr("src");
                        if(scr.indexOf("15@2x.png")>0){
                            layer.msg("完成后,不允许删除", {icon: 2});
                            return;
                        }
                    }
                }
                var ids = [];
                checkbox.each(function (i, v) {
                    var _a = $(v).attr("value");
                    ids.push(_a);
                });
                var ids = ids.join(',');
                layer.confirm('确定删除文件吗？', function (index) {
                    layerAjax('/supervisor/projectManager/deleteFile', {"ids": ids,"type":'hwqd'}, '', function (d) {
                        if(d.flag){
                            checkbox.each(function (i, v) {
                                if ($(v).parent("div").length > 0) {
                                    $(v).parent().nextAll().remove();
                                }
                                $(v).parent().remove();
                            });
                            layer.msg("删除成功！");
                        }else{
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });
            },
            exportFile: function (object) {
                var input = $(object).parent().find("input");
                var id = $(input).attr("value");
                layerAjaxGet("/supervisor/projectManager/rightControl", {"id": id}, '', function (d) {
                    if(d.flag){
                        window.open("/supervisor/projectManager/exportFile?id=" + id);
                        // layer.msg(d.msg, {icon: 6});
                    }else{
                        layer.msg(d.msg, {icon: 5});
                    }
                })
            },
            addForm: function (object) {
                var laydata = eval('(' + $(object).parent().find(".img-upload").attr("lay-data") + ')');
                var type = laydata.type;
                var fbCode = laydata.code;
                if (fbCode == undefined) {
                    fbCode = "";
                }
                var fbId = '';
                if (laydata.pcid) {
                    fbId = laydata.pcid;
                } else {
                    // 到货验收
                    if(type=='038'  ||  type=='039' ||    type=='040'  ||    type=='041'  || type=='042'  || type=='043' || type=='044' || type=='045'){
                        fbId = $(".layui-this").attr("value");
                    }
                }
                if (!fbId) {
                    fbId = "";
                }

                var title = laydata.title;
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width() - 200);
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() );
                }
                var url = "/supervisor/projectManager/addForm?type=" + type + "&id=" + jsondata.id + "&spmId=" + jsondata.spmId + "&stageId=" + jsondata.stageId + "&fbCode=" + fbCode + "&fbId=" + fbId;
                parent.layer.open({
                    id: 'form-add',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url,
                    end: function () {
                        if ($(document).find(".DetailsLf ul li.selected").length > 0) {
                            localStorage.setItem("noPageMove","1");
                            $(document).find(".DetailsLf ul li.selected").click();
                            var  lcId=$(document).find(".DetailsLf ul li.selected").find("span").attr("value");
                            var  jdId=$(document).find(".DetailsLf ul li.selected").find("span").attr("lay-jd");
                            //获取该阶段的状态
                            // 获取里程状态、获取阶段状态
                            var lcjdjon={
                                lcId:lcId,
                                jdId:jdId
                            }
                            layerAjaxGet('/supervisor/projectManager/getLcJdStatus', lcjdjon, '', function (d) {
                                if (d.flag == true) {
                                    var  lc_status=d.data.lc_status;
                                    var  jd_status=d.data.jd_status;
                                    if(lc_status=='1'){
                                        $(document).find(".DetailsLf ul li.selected").find("img").attr("src","/plugin/common/images/16@2x.png");
                                    }
                                    if(jd_status=='1'){
                                        $(document).find(".DetailsLf ul li.selected").parent().prev().find("img").attr("src","/plugin/common/images/16@2x.png");
                                    }
                                } else {
                                    layer.msg(d.msg, {icon: 2});
                                }
                            });

                        }
                    }
                });
            },
            viewhzdclick: function (object) {
                // 回执单
                var checkbox = $(object).parent().find("[type=checkbox]");
                //获取文件id
                var fileId = $(checkbox).attr("value");
                //获取分包id
                var fbId = $(".layui-this").attr("value");
                var title = "";
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width() - 100);
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() - 100);
                }
                var url = "/supervisor/projectManager/qt-jltz-hzd?fileId=" + fileId + "&fbId=" + fbId;

                layer.open({
                    id: 'form-list',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url
                });

            },
            scImage: function (object) {// 上传图片按钮
                var laydata = eval('(' + $(object).attr("lay-data") + ')');
                if (laydata) {
                    if (laydata.type = '002') {
                        // 上传区域显示
                        $(object).parent().next().css("display", "block");
                        //确认上传按钮显示
                        $(object).parent().find(".qr_uplaod").css("display", "block");
                        //批量删除按钮显示
                        $(object).parent().find(".pl_delete").css("display", "block");
                    }


                } else {
                    // 上传区域显示
                    $(object).parent().next().css("display", "block");
                    //确认上传按钮显示
                    $(object).parent().find(".qr_uplaod").css("display", "block");
                    //批量删除按钮显示
                    $(object).parent().find(".pl_delete").css("display", "block");
                }
            },
            comfirmScImage: function (object) {// 确认上传按钮
                // 针对少数页面 要求展示文件的类型是图片列表的展示形式 定义 laydata
                var laydata = eval('(' + $(object).attr("lay-data") + ')');
                if (laydata != undefined) {
                    if (laydata.type == "imagelist") {
                        var imagemain = $(object).parent().parent().next().find(".main");
                        if (imagemain.length == 0) {
                            layer.msg("请先选择图片后，再上传", {icon: 2});
                        }
                    } else {
                        var imagemain = $(object).parent().next().find(".main");
                        if (imagemain.length == 0) {
                            layer.msg("请先选择图片后，再上传", {icon: 2});
                        }
                    }
                } else {// 处理每个文件下是图片
                    var imagemain = $(object).parent().next().find(".main");
                    if (imagemain.length == 0) {
                        layer.msg("请先选择图片后，再上传", {icon: 2});
                    }
                }
            },
            plDeleteImage: function (object) {// 批量删除点击事件
                // 针对少数页面 要求展示文件的类型是图片列表的展示形式 定义 laydata
                var laydata = eval('(' + $(object).attr("lay-data") + ')');
                if (laydata) {
                    if (laydata.type == "imagelist") {
                        var checkbox = $(object).parent().parent().next().find(".yldemo [type=checkbox]:checked");
                        if (checkbox.length == 0) {
                            layer.msg("请选择图片后，再删除", {icon: 2});
                        }
                    }
                } else {
                    // 处理每个文件下是图片
                    var checkbox = $(object).parent().next().find(".yldemo [type=checkbox]:checked");
                    if (checkbox.length == 0) {
                        layer.msg("请选择图片后，再删除", {icon: 2});
                    }
                }
            },
            imgtoword: function (a) {
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                var _fid = that.parent().find('input[type=checkbox]').attr('value');
                if (_fid) {
                    POBrowser.openWindowModeless('/sys/office/openword?ft=6&fid=' + _fid + '&ftg=' + that.attr("tag"), 'width=1200px;height=800px;', '{}')
                } else {
                    layer.msg('未获取到文件ID。', {icon: 2});
                }
            },
            addspjl : function (a) {
                /*插入文件报审表*/
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                var _fid = that.parent().find('input[type=checkbox]').attr('value');
                var fileJson={
                    fileId:_fid
                }
                layerAjaxGet('/supervisor/projectManager/getLcIsEnd', fileJson, '', function (d) {
                    if(!d.flag){
                        layer.msg(d.msg, {icon: 2});
                        return  false;
                    }else{
                        if(d.data=='1'){
                            layer.confirm('您已经操作过报审表，确定重新操作？', function (index) {
                                if (_fid) {
                                    //插入 报审表
                                    POBrowser.openWindowModeless('/sys/office/openword?ft=12&fid=' + _fid, 'width=1200px;height=800px;', '{}')
                                } else {
                                    layer.msg('未获取到文件ID。', {icon: 2});
                                }
                            })

                        }else{
                            if (_fid) {
                                //插入 报审表
                                POBrowser.openWindowModeless('/sys/office/openword?ft=12&fid=' + _fid, 'width=1200px;height=800px;', '{}')
                            } else {
                                layer.msg('未获取到文件ID。', {icon: 2});
                            }
                        }

                    }
                });
            },
            finish: function (object) {
                layer.confirm('确认要点击完成？', function (index) {
                    var fs_status = $(object).attr("lay-fs");// 标记第几个完成
                    // 里程id
                    var json = {
                        fs_status: fs_status,
                        spmId: jsondata.spmId,
                        typeNum: _prom_page.typeNum,
                        stageId: jsondata.stageId,
                        id: jsondata.id,
                    }
                    var  finishtype=$("#lc_img_left").attr("finishType");
                    if(finishtype){
                        json.finshType = finishtype;
                        var  fbId=$(".layui-this").attr("value");
                        json.fbId=fbId;
                    }

                    var fileType = _prom_page.events.getFileType(object);
                    if (fileType) {
                        json.fileType = fileType;
                    }else{
                        var  laydata=eval('('+ $(object).parent().find("label").find("[type='button']").attr("lay-data")+ ')');
                        if(laydata){
                            json.fileTypePt=laydata.type;
                        }
                    }
                    layerAjax('/supervisor/projectManager/updateFinish', json, '', function (d) {
                        if (!d.flag) {
                            layer.msg(d.msg, {icon: 2});
                            return;
                        }
                        var data = d.data;
                        var status = d.status;
                        var lc_status = data.lc_status;// 里程状态
                        var jd_status = data.jd_status;// 阶段状态
                        var fb_status = data.fb_status;//
                        var progress = data.progress;// 项目进度
                        if (d.flag == true) {
                            //更新进度:
                            if (progress) {
                                _prom_page.events.flushProjectProgress(progress);
                            }
                            // 修改本文件状态为已经完成
                            $(object).parent().prev().find("img").attr("src", "/plugin/common/images/15@2x.png");
                            // 修改里程状态
                            if (lc_status != "") {
                                if (lc_status == '1') {
                                    // 修改里程状态图标为 进行中
                                    $("#lc_img_left").find("img").attr("src", "/plugin/common/images/16@2x.png");
                                    //修改左侧标题 里程状态
                                    $("#lc" + jsondata.spmId).attr("src", "/plugin/common/images/16@2x.png");
                                } else if (lc_status == '2') {
                                    // 修改里程状态图标为 已完成
                                    $("#lc_img_left").find("img").attr("src", "/plugin/common/images/15@2x.png");
                                    //修改左侧标题 里程状态
                                    $("#lc" + jsondata.spmId).attr("src", "/plugin/common/images/15@2x.png");
                                } else if (lc_status == '3') {
                                    // 修改里程状态图标为 超时
                                    $("#lc_img_left").find("img").attr("src", "/plugin/common/images/14@2x.png");
                                    //修改左侧标题 里程状态
                                    $("#lc" + jsondata.spmId).attr("src", "/plugin/common/images/14@2x.png");
                                }
                            }
                            // 修改阶段状态
                            if (jd_status != "") {
                                if (jd_status == '1') {
                                    $("#jd" + jsondata.stageId).attr("src", "/plugin/common/images/16@2x.png");
                                } else if (jd_status == '2') {
                                    //修改左侧标题 里程状态
                                    $("#jd" + jsondata.stageId).attr("src", "/plugin/common/images/15@2x.png");
                                } else if (jd_status == '3') {
                                    //修改左侧标题 里程状态
                                    $("#jd" + jsondata.stageId).attr("src", "/plugin/common/images/14@2x.png");
                                }
                            }
                            if(fb_status!=""){
                                if(fb_status == '1'){
                                    $(".layui-this").find("img").attr("src", "/plugin/common/images/16@2x.png");
                                }else if(fb_status=="2"){
                                    $(".layui-this").find("img").attr("src", "/plugin/common/images/15@2x.png");
                                }

                            }
                            layer.msg("操作成功");
                        } else {
                            layer.msg("操作失败");
                        }
                    });
                });

            },
            getParent:function(a, cn) {
                var parent = $(a).parent();
                if (parent.hasClass(cn)) {
                    return parent;
                } else {
                    return _prom_page.events.getParent(parent, cn);
                }
            },
            getBrief:function(b, bri) {
                if ($(b).prop("tagName") == 'UL') {
                    return undefined;
                }
                var brief = $(b).find("." + bri);
                if (brief.length > 0) {
                    return brief;
                } else {
                    return _prom_page.events.getBrief($(b).parent(), bri);
                }
            },
            getFileType: function (object) {
                var parent = _prom_page.events.getParent($(object), 'downModuleBtn');
                if (parent.find('button.img-upload').length > 0 && parent.find('button.img-upload').attr('lay-data')) {
                    //如果父节点里面有上传按钮,说明不是分包的完成按钮(根据观察,分包的完成按钮跟上传按钮,不在一个div里面)
                    //页面边了,要验证一下这个lay-data里面有没有分包id,如果有分包id那么返回type:
                    var tlayData = eval('(' + parent.find('button.img-upload').attr('lay-data') + ')');
                    if(tlayData && tlayData.fbid){
                        return tlayData.type;
                    }
                    return false;
                } else {
                    //递归,找lay-tab-brief,一直找到UL标签为止
                    var brief = _prom_page.events.getBrief(parent, 'layui-tab-brief');
                    if (brief && brief.length > 0) {
                        //查找带lay-data属性的button按钮
                        var imgUploadBtn = brief.find('button[lay-data]');
                        if (imgUploadBtn.length > 0 && $(imgUploadBtn[0]).attr("lay-data")) {
                            var laydata = eval('(' + $(imgUploadBtn[0]).attr("lay-data") + ')');
                            return laydata.type;
                        }
                    }else{
                        //没有brief
                        //有可能是到货验收,验证一下,到货验收的上传按钮是跟着分包id的,
                        // 所以看看这个上传按钮上面的lay-data里面有没有fbid
                        var uploadBtn = parent.find('button[lay-data]');
                        if(uploadBtn){
                            var tlayData = eval('(' + uploadBtn.attr('lay-data') + ')');
                            if(tlayData && tlayData.fbid){
                                return tlayData.type;
                            }
                        }
                    }
                    return false;
                }
            },
            inituploadImage: function (num, datajson, showType) {
                var loading;
                uploadListIns=upload.render({
                    elem: '.tab' + num,
                    url: '/supervisor/projectManager/addFile',//改成您自己的上传接口
                    multiple: true,
                    auto: false,
                    data: datajson,
                    bindAction: '.imageAction' + num,
                    choose: function (obj) {

                        //将每次选择的文件追加到文件队列
                        var item = this.item;
                        var files = this.files = obj.pushFile();
                        if (showType == "imagelist") {// 针对文件类型是 image
                            // 上传区域显示
                            $(item).parent().parent().parent().next().find("div").eq(0).css("display", "block");
                            //确认上传按钮显示
                            $(".imageAction" + num).css("display", "block");
                            //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                            obj.preview(function (index, file, result) {
                                $(item).parent().parent().parent().next().find(".yldemo").append('<div class="main" style="position:relative;float: left; margin-left: 8px;"><div class="img"><img   style="width: 200px;height: 200px;margin: 5px;5px;" src="' + result + '" alt="' + file.name + '" class="layui-upload-img"></div> <div class="checkbox" style="position:absolute;top:0;right:0;z-index:1000"><input id="box" value="' + index + '" type="checkbox" name="box"></div> <div class="fdImage"  style="position:absolute;bottom:0;right:0;z-index:1000"><img  style="width: 30px;height: 30px;float:right;" src="/plugin/common/images/big.png" onclick="_prom_page.events.imageEnlarge(this)"</div>');
                                $('.pl_delete').on('click', function () {
                                    $(this).parent().parent().next().find(".yldemo [type=checkbox]:checked").each(function (i, v) {
                                        var v_index = $(v).attr("value");
                                        delete files[v_index]; //删除对应的文件
                                        $(v).parent().parent().remove();
                                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                                    });
                                });
                            });
                        } else {// 针对每个文件下的上传图片
                            // 上传区域显示
                            $(item).parent().next().css("display", "block");
                            //确认上传按钮显示
                            $(item).parent().find(".qr_uplaod").css("display", "block");
                            //批量删除按钮显示
                            $(item).parent().find(".pl_delete").css("display", "block");
                            //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                            obj.preview(function (index, file, result) {
                                $(item).parent().next().find(".yldemo").append('<div class="main"  style="position:relative;float: left; margin-left: 8px;"><div class="img"><img   style="width: 200px;height: 200px;margin: 5px;5px;" src="' + result + '" alt="' + file.name + '" class="layui-upload-img"></div> <div class="checkbox"  style="position:absolute;top:0;right:0;z-index:1000"><input id="box"  value="' + index + '" type="checkbox" name="box"></div> <div class="fdImage"  style="position:absolute; bottom: 0;right:0;z-index:1000"><img  style="width: 30px;height: 30px;float:right;" src="/plugin/common/images/big.png" onclick="_prom_page.events.imageEnlarge(this)"</div>');
                                $('.pl_delete').on('click', function () {
                                    $(this).parent().next().find(".yldemo [type=checkbox]:checked").each(function (i, v) {
                                        var v_index = $(v).attr("value");
                                        delete files[v_index]; //删除对应的文件
                                        $(v).parent().parent().remove();
                                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                                    });
                                });
                            });
                        }
                    },
                    before: function (obj) {
                        loading = layer.msg('正在上传', {icon: 16, shade: 0.3, time:0});
                        var item = this.item;
                        if (showType == "imagelist") {
                            var laydata = eval('(' + $(item).attr("lay-data") + ')');
                            datajson.type = laydata.type;
                            datajson.fs_status = laydata.value;
                            var fbid = $(this.item).parents(".layui-tab-content").eq(0).prev().find(".layui-this").attr("value");
                            datajson.fbId = fbid;
                            // 获取填写的部位
                            var positionName = $(item).parent().parent().parent().next().find("[name=positionName]").val();
                            datajson.positionName = positionName;
                      /*      datajson.uploadType = "001";*/
                        } else {
                            //获取文件类型
                            var laydata = $(this.item).parents("ul").eq(0).prev().find("label").find("button").attr("lay-data");
                            var type = eval('(' + laydata + ')').type;
                            datajson.type = type;
                            // 获取文件id
                            datajson.parentId = $(item).parent().find("[type=checkbox]").attr("value");
                            if (datajson.type == '108' || datajson.type == '109' || datajson.type == '087' || datajson.type == '088') {
                                var index_wj = $(item).parents("li").eq(0).index();
                                datajson.positionName = index_wj + 1;
                            } else {
                                // 获取填写的部位
                                var positionName = $(item).parent().next().find("[name=positionName]").val();
                                datajson.positionName = positionName;
                            }
                        }
                    },
                    done: function (res, index, upload) {
                        layer.close(loading);
                        var item = this.item;
                        var flag = res.flag;
                        var filename = res.msg;
                        var data = res.data;

                        if (flag == true) {//
                            if (showType == "imagelist") {
                                var wj_status = data.wj_status;// 文件状态
                                var lc_status = data.lc_status;// 里程状态
                                var jd_status = data.jd_status;// 阶段状态
                                // 删除已经选择的图片
                                $(item).parent().parent().parent().next().find(".main").remove();
                                // 删除队列中的文件
                                delete this.files[index];
                                // 上传区域
                                $(item).parent().parent().parent().next().find("div").eq(0).css("display", "none");
                                //确认上传按钮
                                $(".imageAction" + num).css("display", "none");
                                // 加载图片列表
                                var tablelist = "table" + datajson.type + datajson.fbId;
                                _prom_page.events.inittableImage(datajson, tablelist);
                                //修改本文件图标
                                // 控制本条文件类型的变换
                                if (wj_status == '1') {
                                    if (datajson.fbId != undefined && datajson.fbId != "") {// 分包的情况 样式处理
                                        //到货验收
                                        $("#div_fb_" + datajson.type+"_"+datajson.fbId).find("img").attr("src", "/plugin/common/images/16@2x.png");
                                    } else {
                                        // 修改文件类型状态图标为 进行中
                                        $(item).parent().parent().prev().find("img").attr("src", "/plugin/common/images/16@2x.png");
                                    }
                                }
                                // 更新分包Id 到货验收里程
                                if(datajson.type=="038"  || datajson.type=="039" || datajson.type=="042" || datajson.type=="043" || datajson.type=="044"){
                                    $(item).parents(".layui-tab-content").eq(0).prev().find(".layui-this").find("img").attr("src", "/plugin/common/images/16@2x.png");
                                }
                                // 控制里程状态的变换
                                if (lc_status == '1') {
                                    // 修改里程状态图标为 进行中
                                    $("#lc_img_left").find("img").attr("src", "/plugin/common/images/16@2x.png");
                                    //修改左侧标题 里程状态
                                    $("#lc" + jsondata.spmId).attr("src", "/plugin/common/images/16@2x.png");
                                }
                                if (jd_status == '1') {
                                    // 修改阶段状态为进行中
                                    $("#jd" + jsondata.stageId).attr("src", "/plugin/common/images/16@2x.png");
                                }
                            } else {
                                // 清空部位输入值
                                $(item).parent().next().find("[name=positionName]").val("");
                                // 删除已经选择的图片
                                $(item).parent().next().find(".main").remove();
                                // 删除队列中的文件
                                delete this.files[index];
                                // 隐藏上传div
                                $(item).parent().next().css("display", "none");
                                // 隐藏確定上传按钮
                                $(item).parent().find(".qr_uplaod").css("display", "none");
                                // 隐藏批量删除按钮
                                $(item).parent().find(".pl_delete").css("display", "none");
                                // 加载图片列表
                                var tablelist = "table" + datajson.parentId;
                                _prom_page.events.inittableImage(datajson, tablelist);
                            }

                        } else {
                            layer.msg(res.msg, {icon: 2})
                        }
                    },
                    error: function (index, upload) {
                        layer.msg("文件上传失败", {icon: 2})
                    }
                });
            },
            inittableImage: function (jsonimagedata, tablelist) {
                var flag = false;
                var flagoper = true;
                var v_bfb = "60%";
                var oper="20%";
                var selectta=true;
                if (jsonimagedata.type) {
                    flagoper = false;
                    if (jsonimagedata.type == '108' || jsonimagedata.type == '109' || jsonimagedata.type == '087' || jsonimagedata.type == '088') {
                        flag = true;
                        v_bfb = "64%";
                    }else if(jsonimagedata.type == '093'  || jsonimagedata.type == '043' ){
                        /*变更处理  到货验收图片增加删除按钮*/
                        flag = true;
                        v_bfb = "54%";
                        oper = "20%";
                        if(jsonimagedata.type == '043'){
                            //到货验收图片 添加选择框 用来删除
                            selectta=false;

                        }
                    }else if(jsonimagedata.type == '047'){
                        /*隐蔽验收图片*/
                        flag = false;
                        selectta=false;
                        v_bfb = "42%";
                        oper="12%";
                    }else if(jsonimagedata.type == '036' || jsonimagedata.type == '037'   || jsonimagedata.type == '106'  ){
                        selectta=false;
                    }
                }
                table = layui.table;
                //方法级渲染
                tableIns = table.render({
                    id: tablelist,
                    elem: '#' + tablelist,
                    url: '/supervisor/projectManager/showFileList',
                    where: jsonimagedata,//如果无需传递额外参数，可不加该参
                    cols: [[
                        {checkbox: true,  width: '5%',hide: selectta},
                        {
                            title: '序号', width: '65', templet: function (res) {
                                return res.LAY_INDEX;
                            }
                        },
                        {field: 'positionName', title: '部位', width: '140', align: 'left', hide: flag, sort: true},
                        {field: 'url', title: 'url', width: '30%', hide: true, sort: true},
                        {
                            field: 'fileName', title: '文件名称', width: v_bfb, sort: true, align: 'left',
                            templet: function (d) {
                                return '<img  style="width: 30px;height: 30px;float:left;" src="/plugin/common/images/big.png" onclick="_prom_page.events.viewImage(\'' + d.id + '\',\'' + d.url + '\')">' + d.fileName + ''
                            }
                        },
                        {
                            field: 'createDate',
                            title: '上传时间',
                            align: 'left',
                            width: '190',
                            sort: true,
                            templet: '<div>{{ _prom_page.events.formatdate(d.createDate,"yyyy-MM-dd hh:mm:ss")}}</div>'
                        },
                        {
                            field: 'createDate', title: '操作', width: oper, sort: true,hide:flagoper, align: 'left',
                            templet: function (d) {
                                if(flistdel=='1'  && _model=='m'){
                                    return '<img  style="width: 30px;height: 30px;float:left;" src="/plugin/common/images/del.png" onclick="_prom_page.events.deletefj(\'' + d.id + '\',\'' + tablelist + '\')">'
                                }else{
                                    return '';
                                }

                            }
                        },
                    ]],
                    done: function (res, currentCount) {

                    }
                });
                /*   tableIns.reload(tablelist, {
                       where: jsonimagedata
                   });*/
            },
            //对于分包情况的处理 点击title 动态加载该分包下的文件
            clickChange: function (con_index, fbid, index, laydata, content) {
                // index 第几个 title
                var jsonc = {
                    "projectId": jsondata.id,
                    "id": jsondata.id,
                    "spmId": jsondata.spmId,
                    "stageId": jsondata.stageId,
                    "fbId": fbid,
                    "type": laydata.type,
                    "parentId": "",
                    "positionName": ""
               /*     "uploadType": "001"*/
                }
                var length = $(content).find(".layui-tab-item:eq(" + index + ") ul").find("li").length;
                if (length == 0) {
                    // tab 点击事件中 文件类型分为两种情况 （1） 普通的word 文件 （2） 文件类型为 图片
                    var showType = laydata.showType;// 获取文件类型展示形式
                    if (showType == 'imagelist') {// 文件是以table列表的展示形式图片
                        //加载图片列表 table 所有的图片列表 table 命名 都是 table+文件类型+分包id 以确保tableid 不重复
                        var tablelist = "table" + laydata.type + fbid;

                        _prom_page.events.inittableImage(jsonc, tablelist);
                        // 绑定上传按钮
                        var numtype = laydata.type + fbid;
                        _prom_page.events.inituploadImage(numtype, jsonc, 'imagelist');

                    } else {// 普通文件上传后的展示形式
                        _prom_page.events.butKzInit();
                        layerAjaxGet('/supervisor/projectManager/getFbList', jsonc, '', function (d) {
                            if (d.flag == true) {
                                if (button_array != undefined && button_array != null) {
                                    button_array.length = 0;
                                }
                                for (var i = 0; i < d.data.length; i++) {
                                    num = num - 1;
                                    var filename = d.data[i].fileName;
                                    var id = d.data[i].id;
                                    var type = d.data[i].type;
                                    var lcStatus = d.data[i].lcStatus;
                                    if(lcStatus==null || lcStatus=="null"){
                                        lcStatus="";
                                    }
                                    var bt = $(content).find(".layui-tab-item:eq(" + index + ") button").attr("bt-data");
                                    // 如果页面没有定义样式
                                    if (bt == undefined || bt == "" || bt == null) {
                                        bt = "[]";
                                    }
                                    button_array = eval('(' + bt + ')');
                                    if (button_array.indexOf("sc_image") > 0) {
                                        var li_str = '<li class=\"clearfix\"><div class="clearfix"><input type=\"checkbox\" class=\"fl\"  title=\"jian\"  value=' + id + '><span class=\"fl ml10\">' + filename + '</span>';
                                    } else {
                                        var li_str = '<li class=\"clearfix\"><input type=\"checkbox\" class=\"fl\"  title=\"jian\"  value=' + id + '><span class=\"fl ml10\">' + filename + '</span>';
                                    }
                                    if (button_array.indexOf("upfj") > 0) {
                                        var li_str = '<li class=\"clearfix\"><div class="clearfix"><input type=\"checkbox\" class=\"fl\"  title=\"jian\"  value=' + id + '><span class=\"fl ml10\">' + filename + '</span>';
                                    }

                                    if (button_array.length > 0) {
                                        for (j = button_array.length - 1; j > -1; j--) {
                                            if (button_array[j] == 'c'  && fview=="1") {// 查看按鈕
                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_view" onclick="_prom_page.events.viewclick(this)"  >查看</button>';
                                            } else if (button_array[j] == 'd' && fexport=="1") {//导出
                                                li_str = li_str + '<button type="button" class="fr mt15 bgnone ml20" onclick="_prom_page.events.exportFile(this)">导出</button>'
                                            } else if (button_array[j] == 'q' && fsign=="1") {// 签字
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_gz" onclick="_prom_page.events.gzclick(this)" >签字</button>';
                                                }

                                            } else if (button_array[j] == 'g'  && fupseal=="1") {// 盖章
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_gz" onclick="_prom_page.events.gzclick(this)">盖章</button>';
                                                }
                                            } else if (button_array[j] == 'sp') {// 内部审批
                                                if(_model=='m'){
                                                    if ("'0','1','3'".indexOf(lcStatus) > 0 || lcStatus == "") {
                                                        if(jlsp=="1"){
                                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jlnbsp" onclick="_prom_page.events.jlnbspclick(this)" >审批</button>';
                                                        }

                                                    }
                                                }
                                            } else if (button_array[j] == 'sh') {// 内部审核
                                                if(_model=='m'){
                                                    if ("'0','1','3'".indexOf(lcStatus) > 0 || lcStatus == "") {
                                                        if(jlsh=="1"){
                                                           li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jlnbsh" onclick="_prom_page.events.jlnbshclick(this)" >审核</button>';
                                                        }
                                                    }
                                                }

                                            } else if (button_array[j] == 'jf3') {// 监发三签承发三签
                                                if(_model=='m'){
                                                    if (button_array.indexOf("sp") > 0 ||  button_array.indexOf("sh") > 0) {
                                                        //一开始上传的时候含有这两个按钮 不显示这个
                                                        if ("'2','4','6'".indexOf(lcStatus) > 0 ) {
                                                            if(jfsq=="1") {
                                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jfsq"   onclick="_prom_page.events.jfsqclick(this)" >监发三签</button>';
                                                            }
                                                            if(isyz=='1'){
                                                               /*业主单位签章上传*/
                                                               //li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                           }

                                                        }
                                                    }else{
                                                        /*不含有审核 审批 */
                                                        if ("'2','4','6'".indexOf(lcStatus) > 0 ||  lcStatus =="" ||  lcStatus ==null) {
                                                            if(jfsq=="1") {
                                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jfsq"   onclick="_prom_page.events.jfsqclick(this)" >监发三签</button>';
                                                            }
                                                            if(isyz=='1'){
                                                                /*业主单位签章上传*/
                                                                //li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                            }
                                                        }
                                                    }

                                                }

                                            } else if (button_array[j] == 'cf3') {// 承发三签
                                                if(_model=='m'){
                                                    if (button_array.indexOf("sp") > 0 || button_array.indexOf("sh") > 0) {
                                                        if ("'2','4','6'".indexOf(lcStatus) > 0 ) {
                                                            if(cfsq=="1"){
                                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_cfsq"   onclick="_prom_page.events.cfsqclick(this)" >承发三签</button>';
                                                            }
                                                            if(isyz=='1') {
                                                                /*业主单位签章上传*/
                                                                //li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                            }
                                                        }
                                                    }else{
                                                        /*不含有审核 审批 */
                                                        if ("'2','4','6'".indexOf(lcStatus) > 0 ||  lcStatus =="" ||  lcStatus ==null) {
                                                            if(cfsq=="1"){
                                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_cfsq"   onclick="_prom_page.events.cfsqclick(this)" >承发三签</button>';
                                                            }
                                                            if(isyz=='1') {
                                                                /*业主单位签章上传*/
                                                                //li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                            }
                                                        }
                                                    }
                                                }

                                            } else if (button_array[j] == 'jf2') {// 监发两签
                                                if(_model=='m'){
                                                    if (button_array.indexOf("sp") > 0 ||  button_array.indexOf("sh") > 0) {
                                                        /*含有审核 审批 */
                                                        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
                                                        if ("'2','4','6'".indexOf(lcStatus) > 0 ) {
                                                            if(jflq=="1") {
                                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jflq"   onclick="_prom_page.events.jflqclick(this)" >监发两签</button>';
                                                            }
                                                            if(isyz=='1') {
                                                              /*业主单位签章上传*/
                                                              //li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                            }
                                                        }
                                                    }else{
                                                        /*不含有审核 审批 */
                                                        if ("'2','4','6'".indexOf(lcStatus) > 0 ||  lcStatus =="" ||  lcStatus ==null) {
                                                            if(jflq=="1") {
                                                                li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone btn_jflq"   onclick="_prom_page.events.jflqclick(this)" >监发两签</button>';
                                                            }
                                                            if(isyz=='1') {
                                                                /*业主单位签章上传*/
                                                                //li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                            }
                                                        }
                                                    }
                                                }

                                            } else if (button_array[j] == 'sc_image' && fupimg=="1") {// 上传图片
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone upImage tab' + num + '"  onclick="_prom_page.events.scImage(this)">上传图片</button>';
                                              }

                                            } else if (button_array[j] == 'qr_uplaod'  && fupimg=="1") {// 确认上传
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button"  style="display: none;" class="fr ml20 mt15 bgnone qr_uplaod  imageAction' + num + '"  onclick="_prom_page.events.comfirmScImage(this)" >确认上传</button>';
                                                  }
                                            } else if (button_array[j] == 'pl_delete'  && fupimg=="1") {// 批量删除
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button" style="display: none;" class="fr ml20 mt15 bgnone pl_delete" onclick="_prom_page.events.plDeleteImage(this)" >删除图片</button>';
                                                }
                                            } else if (button_array[j] == 'img_in'  && fupimg=="1") {// 插入图片
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone" tag="PO_CIMG" onclick="_prom_page.events.imgtoword(this)">插入图片</button>';
                                                }
                                            }else if(button_array[j] == 'upfj'){
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone upfj tabup' + num + '"  >上传附件</button>';

                                                }
                                            }else if(button_array[j] == 'addspjl'){
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button"  class="fr ml20 mt15 bgnone  addspjl"   onclick="_prom_page.events.addspjl(this)" >报审表</button>';
                                                }
                                            } else if(button_array[j] == 'upseal'){
                                                /*业主单位签章上传*/
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button"   class="fr ml20 mt15 bgnone upseal tabsealup' + num + '""  >上传签章</button>';
                                                }

                                            } else if(button_array[j] == 'pl_delete_image'){
                                                /*批量删除图片*/
                                                if(_model=='m'){
                                                    li_str = li_str + '<button type="button"   class="fr ml20 mt15 bgnone btn_deletepic"    onclick="_prom_page.events.delpicPt(\'table'+id+'\')">删除附件</button>';
                                                }

                                            }



                                        }
                                    } else {// 追加默认样式
                                        if(fexport=="1"){
                                            li_str = li_str + '<button type="button" class="fr ml20 mt15 bgnone"  onclick="_prom_page.events.exportFile(this)">导出</button>';
                                        }
                                        if(fview=="1"){
                                            li_str = li_str + '<button type="button" class="fr mt15 bgnone ml20 btn_view" onclick="_prom_page.events.viewclick(this)">查看</button>';
                                        }
                                    }
                                    if (button_array.indexOf("sc_image") > 0) {
                                        if (type == '108' || type == '087') {
                                            //承建付款申请  没有部位
                                            li_str = li_str + '</div><div  style="position:relative;float: left; border: 1px solid #EEEEEE;height: 300px;width: 98%; overflow-y: scroll;display: none"><div  style="clear: both;"></div><div class="layui-upload-list yldemo"></div><div  style="clear: both;"></div></div><div  style="border: 1px solid rgb(238, 238, 238);float: left;display: inline-block;width: 98%;"><table id="table' + id + '" style="height: 300px;width: 80%;" class="layui-hide" lay-filter="table' + id + '"></table><div  style="clear: both;"></div></div><div  style="clear: both;"></div>';
                                        } else {
                                            li_str = li_str + '</div><div  style="position:relative;float: left; border: 1px solid #EEEEEE;height: 300px;width: 98%; overflow-y: scroll;display: none"><!--<label class="fl"style="margin-top: 15px;" ><span class="red">*</span>请填写部位</label>--><input type="text"  placeholder="请填写部位"  autocomplete="off" style="margin-left: 12px;width: 400px;" name="positionName"   class="fl" value=""><div  style="clear: both;"></div><div class="layui-upload-list yldemo"></div><div  style="clear: both;"></div></div><div  style="border: 1px solid rgb(238, 238, 238);float: left;display: inline-block;width: 98%;"><table id="table' + id + '" style="height: 300px;width: 80%;" class="layui-hide" lay-filter="table' + id + '"></table><div  style="clear: both;"></div></div><div  style="clear: both;"></div>';
                                        }

                                    }

                                   if (button_array.indexOf("upfj") > 0) {
                                            li_str = li_str + '</div><div  style="position:relative;float: left; border: 1px solid #EEEEEE;height: 300px;width: 98%; overflow-y: scroll;display: none"><label class="fl"style="margin-top: 15px;" ><div class="layui-upload-list yldemo"></div><div  style="clear: both;"></div></div><div  style="border: 1px solid rgb(238, 238, 238); float:left;display: inline-block;width: 98%;"><table id="table' + id + '" style="height: 300px;" class="layui-hide" lay-filter="table' + id + '"></table></div><div style="clear:both;"></div>';
                                    }

                                    li_str = li_str + "</li>";
                                    $(content).find(".layui-tab-item:eq(" + index + ") ul").append(li_str);
                                    //每个文件后面初始化 table  列表
                                    if (button_array != null) {
                                        if (button_array.indexOf("sc_image") > 0) {// 给上传图片按钮绑定 事件
                                            // 初始化图片列表
                                            var jsonimagedata = {
                                                "id": jsondata.id,
                                                "spmId": jsondata.spmId,
                                                "stageId": jsondata.stageId,
                                                "fbId": jsonc.fbId,
                                                "parentId": id,
                                                "positionName": "",
                                                "uploadType": "002"  // 查询形式 每个文件下面有图片
                                            }
                                            jsonimagedata.parentId = id;
                                            jsonimagedata.type = type;
                                            var tablelist = "table" + id;
                                            _prom_page.events.inittableImage(jsonimagedata, tablelist);
                                        }
                                        if (button_array.indexOf("upfj") > 0) {// 给上传图片按钮绑定 事件
                                            // 初始化图片列表
                                            var jsonimagedata = {
                                                "id": jsondata.id,
                                                "spmId": jsondata.spmId,
                                                "stageId": jsondata.stageId,
                                                "fbId": jsonc.fbId,
                                                "parentId": id,
                                                "positionName": "",
                                                "uploadType": "002"  // 查询附件
                                            }
                                            jsonimagedata.parentId = id;
                                            jsonimagedata.type = type;
                                            var tablelist = "table" + id;
                                            _prom_page.events.inittableImage(jsonimagedata, tablelist);
                                        }

                                    }
                                    // 给每次ajax调用后的上传图片按钮添加上传监听事件
                                    if (button_array != null) {
                                        if (button_array.indexOf("sc_image") > 0) {// 给上传图片按钮绑定 事件
                                            var jsonimagedata = {
                                                "id": jsondata.id,
                                                "spmId": jsondata.spmId,
                                                "stageId": jsondata.stageId,
                                                "fbId": jsonc.fbId,
                                                "parentId": "",
                                                "positionName": "",
                                                "uploadType": "002"  // 查询形式 每个文件下面有图片 的上传形式
                                            }
                                            jsonimagedata.parentId = id;
                                            // 文件类型
                                            jsonimagedata.type = jsondata.type;
                                            _prom_page.events.inituploadImage(num, jsonimagedata, "filelist");
                                        }
                                        if (button_array.indexOf("jf2") > 0  || button_array.indexOf("jf3") > 0  || button_array.indexOf("cf3") > 0 ) {// 给上传图片按钮绑定事件
                                            var jsonimagedata = {
                                                "id": jsondata.id,
                                                "spmId": jsondata.spmId,
                                                "stageId": jsondata.stageId,
                                                "fbId": jsondata.fbId,
                                                "parentId": "",
                                                "positionName": "",
                                                "uploadType": "002"
                                            }
                                            jsonimagedata.parentId = id;
                                            jsonimagedata.type = jsondata.type;
                                            _prom_page.events.uploadfjinit(num,'seal');
                                        }
                                        if (button_array.indexOf("upfj") > 0) {// 给上传图片按钮绑定 事件
                                            var jsonimagedata = {
                                                "id": jsondata.id,
                                                "spmId": jsondata.spmId,
                                                "stageId": jsondata.stageId,
                                                "fbId": jsonc.fbId,
                                                "parentId": "",
                                                "positionName": "",
                                                "uploadType": "002"  // 查询形式 每个文件下面有图片 的上传形式
                                            }
                                            jsonimagedata.parentId = id;
                                            // 文件类型
                                            jsonimagedata.type = jsondata.type;
                                            _prom_page.events.uploadfjinit(num,"");
                                        }
                                    }

                                }



                            } else {
                                layer.msg(d.msg, {icon: 2});
                            }
                        });
                        _prom_page.events.butKzInit();
                    }
                }

                // 按钮灰色 针对到货验收（其他页面按钮状态通过后台初始化页面参数时 已经设置）
                _prom_page.events.butFinishStatusInit();
            },
            viewclick: function (a) {
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                var _fid = that.parent().find('input[type=checkbox]').attr('value');
                if (_fid) {
                    layerAjaxGet('/supervisor/projectManager/selectfile',{id:_fid},'',function (b) {
                        var fileExtension = b.url.substring(b.url.lastIndexOf('.') + 1).toLowerCase();
                        if(fileExtension=='jpg'||fileExtension=='jpeg'||fileExtension=='png'||fileExtension=='gif'){
                            var imgSrc = b.url;
                            var w = ($(window).width() *0.9);
                            var h = ($(window).height() *0.9);
                            imgSrc=imgSrc+"?v="+Math.random();
                           // getImageWidth(imgSrc,function(imgW,imgH){
                            getImageWidth(imgSrc,w,h,function(imgW,imgH){



                                // if(imgW*1 > w*1){
                                //     imgW = w*1;
                                // }
                                // if(imgH*1 > h*1){
                                //     imgH = h*1;
                                // }
                                layer.open({
                                    type: 1,
                                    title: false,
                                    closeBtn: 1,
                                    area: [imgW+"px",imgH+"px"],
                                    skin: 'layui-layer-nobg', //没有背景色
                                    shadeClose: true,
                                    content: '<img src="/supervisor/projectManager/img?fid=' + _fid + '" height="'+imgH+'px" width="'+imgW+'px" />'
                                });
                            })
                        }else{
                            if(_model=='m'){
                                //编辑
                                POBrowser.openWindowModeless('/sys/office/openword?ft=10&fid=' + _fid, 'width=1200px;height=800px;', '{}')
                            }else{
                                //查看
                                POBrowser.openWindowModeless('/sys/office/openword?ft=3&fid=' + _fid, 'width=1200px;height=800px;', '{}')
                            }
                        }
                    })

                } else {
                    layer.msg('未获取到文件ID。', {icon: 2});
                }
            },
            gzclick: function (a) {
                // 盖章
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                var _fid = that.parent().find('input[type=checkbox]').attr('value');
                if (_fid) {
                    POBrowser.openWindowModeless('/sys/office/openword?ft=9&fid=' + _fid, 'width=1200px;height=800px;', '{}')
                } else {
                    layer.msg('未获取到文件ID。', {icon: 2});
                }
            },
            dzsignclick: function (a) {
                // 签字
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                var _fid = that.parent().find('input[type=checkbox]').attr('value');
                if (_fid) {
                    POBrowser.openWindowModeless('/sys/office/openword?ft=8&fid=' + _fid, 'width=1200px;height=800px;', '{}')
                } else {
                    layer.msg('未获取到文件ID。', {icon: 2});
                }
            },
            deptcheckclick: function (a) {
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                // 文件id
                var fileId = that.parent().find('input[type=checkbox]').attr('value');
                // 项目id
                var projectId = jsondata.id;
                var spanfile = that.parent().find("span").html()
                var fileName = spanfile.substring(0, spanfile.indexOf('.'));
                var jsonsp = {
                    type: "006",//监理内部审批流程
                    projectId: projectId,
                    fileId: fileId,
                    fileName: fileName
                }
                layer.confirm('确定发起审批流程吗？', function (index) {
                    layerAjax('/supervisor/lcManager/updateStartLc', jsonsp, '', function (d) {
                        if (d.flag == true) {
                            layer.msg(d.msg);
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });

            },
            delpic:function(tableid){
                // 图片列表  批量删除图片
                var checkStatus = table.checkStatus('table043'+tableid);
                var data = checkStatus.data;
                //获取选中数量
                var selectCount = checkStatus.data.length;
                if (data.length == 0) {
                    layer.msg('请选择文件进行删除。', {icon: 5});
                    return false;
                }
                layer.confirm('确定删除吗？', function (index) {
                    var ids = [];
                    for (var i = 0; i < selectCount; i++) {
                        ids.push(checkStatus.data[i].id);
                    }
                    var ids = ids.join(',');
                    layerAjax('/supervisor/projectManager/deleteFile', {"ids": ids}, '', function (d) {
                        if(d.flag){
                            layer.msg("删除成功！");
                            table.reload('table043'+tableid,{});
                        }else{
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });

            },
            delpicPt:function(tableid){
                // 图片列表  批量删除图片
                var checkStatus = table.checkStatus(tableid);
                var data = checkStatus.data;
                //获取选中数量
                var selectCount = checkStatus.data.length;
                if (data.length == 0) {
                    layer.msg('请选择附件进行删除。', {icon: 5});
                    return false;
                }
                layer.confirm('确定删除吗？', function (index) {
                    var ids = [];
                    for (var i = 0; i < selectCount; i++) {
                        ids.push(checkStatus.data[i].id);
                    }
                    var ids = ids.join(',');
                    layerAjax('/supervisor/projectManager/deleteFile', {"ids": ids}, '', function (d) {
                        if(d.flag){
                            layer.msg("删除成功！");
                            table.reload(tableid,{});
                        }else{
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });

            },
            jlnbspclick: function (a) {
                // 内部审批按钮触发流程
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                // 文件id
                var fileId = that.parent().find('input[type=checkbox]').attr('value');
                // 项目id
                var projectId = jsondata.id;
                var spanfile = that.parent().find("span").html()
                var fileName = spanfile.substring(0, spanfile.indexOf('.'));
                var jsonsp = {
                    type: "001",//监理内部审批流程
                    projectId: projectId,
                    fileId: fileId,
                    fileName: fileName
                }
                layer.confirm('提示：如果没有上传监理项目用章授权书，请上传后再发起流程。确定发起审批流程吗？', function (index) {
                    layerAjax('/supervisor/lcManager/updateStartLc', jsonsp, '', function (d) {
                        if (d.flag == true) {
                            layer.msg(d.msg);
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });

            },
            jlnbshclick: function (a) {
                // 内部审核按钮触发流程
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                // 文件id
                var fileId = that.parent().find('input[type=checkbox]').attr('value');
                // 项目id
                var projectId = jsondata.id;
                var spanfile = that.parent().find("span").html()
                var fileName = spanfile.substring(0, spanfile.indexOf('.'));
                var jsonsp = {
                    type: "002",//监理内部审核流程
                    projectId: projectId,
                    fileId: fileId,
                    fileName: fileName
                }
                layer.confirm('提示：如果没有上传监理项目用章授权书，请上传后再发起流程。确定发起审核流程吗？', function (index) {
                    layerAjax('/supervisor/lcManager/updateStartLc', jsonsp, '', function (d) {
                        if (d.flag == true) {
                            layer.msg(d.msg);
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });

            },
            jflqclick: function (a) {
                // 监发两签
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                // 文件id
                var fileId = that.parent().find('input[type=checkbox]').attr('value');
                // 项目id
                var projectId = jsondata.id;
                var spanfile = that.parent().find("span").html()
                var fileName = spanfile.substring(0, spanfile.indexOf('.'));
                var jsonsp = {
                    type: "003",//监发两签
                    projectId: projectId,
                    fileId: fileId,
                    fileName: fileName
                }
                var title = "";
                layer.confirm('提示：如果没有上传监理项目用章授权书，请上传后再发起流程。确定发起监发两签吗？', function (index) {
                    var url = "/supervisor/lcManager/lcselectJsr?type=003&projectId=" + projectId + "&fileId=" + fileId + "&fileName=" + fileName;
                    layer.open({
                        id: 'form-add',
                        type: 2,
                        area: ['600px', '400px'],
                        fix: false,
                        maxmin: true,
                        shadeClose: false,
                        shade: 0.4,
                        title: title,
                        content: url,
                        end: function () {
                            layer.close(index);
                        }
                    });
                });
            },
            jfsqclick: function (a) {
                // 监发三签
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                // 文件id
                var fileId = that.parent().find('input[type=checkbox]').attr('value');
                // 项目id
                var projectId = jsondata.id;
                var spanfile = that.parent().find("span").html()
                var fileName = spanfile.substring(0, spanfile.indexOf('.'));
                var jsonsp = {
                    type: "004",//监发三签
                    projectId: projectId,
                    fileId: fileId,
                    fileName: fileName
                }
                var title = "";
                var url = "/supervisor/lcManager/lcselectJsr?type=004&projectId=" + projectId + "&fileId=" + fileId + "&fileName=" + fileName;
                layer.confirm('提示：如果没有上传监理项目用章授权书，请上传后再发起流程。确定发起监发三签吗？', function (index) {
                    layer.open({
                        id: 'form-add',
                        type: 2,
                        area: ['600px', '400px'],
                        fix: false,
                        maxmin: true,
                        shadeClose: false,
                        shade: 0.4,
                        title: title,
                        content: url,
                        end: function () {
                            layer.close(index);
                        }
                    });
                });
            },
            cfsqclick: function (a) {
                // 承发三签
                var that = $(this);
                if (!that.is('button')) {
                    that = $(a);
                }
                //分包Id
                var fbId = that.parents(".layui-tab-content").eq(0).prev().find(".layui-this").attr("value");
                // 文件id
                var fileId = that.parent().find('input[type=checkbox]').attr('value');
                // 项目id
                var projectId = jsondata.id;
                var spanfile = that.parent().find("span").html()
                var fileName = spanfile.substring(0, spanfile.indexOf('.'));
                var jsonsp = {
                    type: "005",//承发三签
                    projectId: projectId,
                    fileId: fileId,
                    fileName: fileName,
                    fbId: fbId
                }
                layer.confirm('提示：多个承建单位签字需线下走完流程，上传签章图片。如果没有上传监理项目用章授权书，请上传后再发起流程。确定发起承发三签吗？', function (index) {
                    layerAjax('/supervisor/lcManager/updateStartLc', jsonsp, '', function (d) {
                        if (d.flag == true) {
                            layer.msg(d.msg);
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });

            },
            flushProjectProgress:function(a) {
                $("#proprogress").css('width', a + '%');
                if(a && parseFloat(a)<5 && parseFloat(a)>0){
                    $("#proprogress").css("width","5%");
                }
                $("#proprogress").find('span').text(a + '%');
                //刷新管理项目页面的列表：
                var pmFrameUrl = localStorage.getItem("pmFrameUrl");
                if(pmFrameUrl){
                    var pmFrame = $(window.parent.document).find('iframe[src="'+pmFrameUrl+'"]');
                    var pmWindow = pmFrame[0].contentWindow;
                    var docu = pmWindow.document;
                    pmWindow.query();
                    //重新设置宽度，不然会挤在一起
                    pmWindow.resiztProjectTable();
                }
            },
            checkfilecount:function(o) {
                var that = $(o);
                var _a = eval('(' + that.attr("lay-data") + ')');
                var _b = that.parent().parent().parent().next().find('li').length;
                if (_a.filecount) {
                    if (_b >= _a.filecount) {
                        layer.msg("最大允许上传" + _a.filecount + "个文件", {icon: 2});
                        var e = (e) ? e : ((window.event) ? window.event : null);
                        e.stopPropagation();
                        e.preventDefault();
                    }
                }
            },
            jdjc: function (object) {
                var checkbox = $(object).parent().find("[type=checkbox]");
                //获取文件id
                var fileId = $(checkbox).attr("value");
                //获取分包id
                var fbId = $(checkbox).attr("fbid");
                var title = "";
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width());
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() - 50);
                }
                var url = "/supervisor/projectManager/dhys-jdjy?fileId=" + fileId + "&fbId=" + fbId;
                parent.layer.open({
                    id: 'form-list',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: false,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url
                });
            },
            kxjy: function (object) {
                var checkbox = $(object).parent().find("[type=checkbox]");
                //获取文件id
                var fileId = $(checkbox).attr("value");
                //获取分包id
                var fbId = $(checkbox).attr("fbid");
                var title = "";
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width());
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() - 50);
                }
                var url = "/supervisor/projectManager/dhys-kxjy?fileId=" + fileId + "&fbId=" + fbId;
                parent.layer.open({
                    id: 'form-list',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: false,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url
                });
            },
            wdTj: function (object) {
                // 文档统计 获取项目id
                var projectId = jsondata.id;
                var title = "";
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width());
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() - 50);
                }
                var url = "/supervisor/projectManager/viewTj?projectId=" + projectId;
                parent.layer.open({
                    id: 'form-list',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url,
                    success: function(layero){
                        layero.find('.layui-layer-min').remove();
                    }
                });
            },
            bigEvent: function (object) {
                // 项目大事记 获取项目id
                var projectId = jsondata.id;
                var title = "";
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width());
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() - 50);
                }
                var url = "/supervisor/projectManager/viewBigEvent?projectId=" + projectId;
                parent.layer.open({
                    id: 'form-list',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url,
                    success: function(layero){
                        layero.find('.layui-layer-min').remove();
                    }
                });
            },
            viewSealReocrd: function (object) {
                // 用章记录获取项目id
                var projectId = jsondata.id;
                var title = "";
                var w = "";
                var h = "";
                if (w == null || w == '') {
                    w = ($(window).width());
                }
                ;
                if (h == null || h == '') {
                    h = ($(window).height() - 50);
                }
                var url = "/supervisor/projectManager/viewSealReocrd?projectId=" + projectId;
                parent.layer.open({
                    id: 'form-list',
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url,
                    success: function(layero){
                        layero.find('.layui-layer-min').remove();
                    }
                });
            },
            viewImage: function (a,b) {
                var url=b;
                var fileExtension = b.substring(b.lastIndexOf('.') + 1).toLowerCase();
                if(fileExtension.indexOf("doc")!=-1 ||fileExtension.indexOf("docx")!=-1 ||  fileExtension.indexOf("xlsx")!=-1 ||fileExtension.indexOf("xls")!=-1){
                    POBrowser.openWindowModeless('/sys/office/openword?ft=3&fid=' + a, 'width=1200px;height=800px;', '{}')
                }else{
                    layer.open({
                        type: 1
                        ,
                        offset: 't'
                        ,
                        id: 'layerDemoauto' //防止重复弹出
                        ,
                        area: ['600px', '600px']
                        ,
                        content: '<img width=\'100%\' height=\'100%\'  src="/supervisor/projectManager/img?fid=' + a + '" >'
                        ,
                        btn: '关闭'
                        ,
                        btnAlign: 'c' //按钮居中
                        ,
                        title: "图片详情"
                        ,
                        shade: 0.4//不显示遮罩
                        ,
                        yes: function () {
                            layer.closeAll();
                        }
                    });
                }


            },
            deletefj: function (a,tablelist) {
                var ids = [];
                ids.push(a);
                var ids = ids.join(',');
                layer.confirm('确定删除文件吗？', function (index) {
                    layerAjax('/supervisor/projectManager/deleteFile', {"ids": ids}, '', function (d) {
                        if(d.flag){
                            layer.msg("删除成功！");
                            table.reload(tablelist,{});
                        }else{
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                });
            },

            getProgram: function (bgreason) {
                if(bgreason){
                    var json={
                        keyword:bgreason
                    }
                    layerAjaxGet('/sys/base/programManager/queryPro', json, '', function (d) {
                        if (d.flag == true) {
                            var data=d.data;
                            var programId=data.programId;
                            if(programId){
                                var w = ($(window).width() * 0.9);
                                var h = ($(window).height() - 50);
                                layer.open({
                                    id: 'type-add',
                                    type: 2,
                                    area: [w + 'px', h + 'px'],
                                    fix: false,
                                    maxmin: true,
                                    shadeClose: false,
                                    shade: 0.4,
                                    title: "预案信息",
                                    content: '/sys/base/programManager/detail?programId=' + programId,
                                    yes: function () {
                                    },
                                    btn2: function () {
                                        layer.closeAll();
                                    },
                                    zIndex: layer.zIndex, //重点1,
                                    success: function (layero) {
                                        layer.setTop(layero); //重点2
                                    },
                                    end: function () {
                                    }
                                });
                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                }
            },
            imageEnlarge: function (object) {
                //图片放大
                var  url= $(object).parents(".main").find(".img").find("img").attr("src");
                var imgHtml = "<img src='" +url+ "' width='100%' height='100%'/>";
                layer.open({
                    type: 1
                    ,
                    offset: 't'
                    ,
                    id: 'layerDemoauto' //防止重复弹出
                    ,
                    area: ['600px', '600px']
                    ,
                    content: imgHtml
                    ,
                    btn: '关闭'
                    ,
                    btnAlign: 'c' //按钮居中
                    ,
                    title: "图片详情"
                    ,
                    shade: 0.4//不显示遮罩
                    ,
                    yes: function () {
                        layer.closeAll();
                    }
                });
            },
            openZfcs: function (fileId) {
                var projectId = jsondata.id;
                //获取文件id

                var title = "";
                var url = "/supervisor/projectManager/openZfcs?projectId=" + projectId + "&fileId=" + fileId;
                layer.open({
                    id: 'form-list',
                    type: 2,
                    area: ['600px', '400px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: title,
                    content: url
                });
            },
            butFinishStatusInit :function() {
                //针对到货验收完成按钮 状态（是否至灰）
                    $(".btn_finish").each(function (i, v) {
                        var  lay_data=$(v).parent().find("label").find("[type=button]");
                        if(lay_data.length>0){
                            var  laydata=eval('('+lay_data.attr("lay-data")+')');
                            if(laydata){
                                if(laydata.type=="038" || laydata.type=="039" ||  laydata.type=="045" ||laydata.type=="060" ){
                                    // 该页面其他文件类型不需要审核
                                    //审核
                                    var  shlengh=$(v).parent().parent().next().find(".btn_jlnbsh").length;
                                    //审批
                                    var  sqlengh=$(v).parent().parent().next().find(".btn_jlnbsp").length;
                                    //承发三签
                                    var  cfsqlengh=$(v).parent().parent().next().find(".btn_cfsq").length;
                                    //监发两签
                                    var  jflqlengh=$(v).parent().parent().next().find(".btn_jflq").length;
                                    //监发三签
                                    var  jfsqlengh=$(v).parent().parent().next().find(".btn_jfsq").length;
                                    if(shlengh>0 || sqlengh>0 ){
                                        $(v).addClass("layui-btn-disabled").attr("disabled",true);
                                    }
                                }

                            }

                        }

                    });
            },
            butKzInit :function() {
                if (_model!='m'){
                    $('.downModuleBtn').hide();
                    $('.btn_dzsign').hide();
                    $('.btn_gz').hide();
                    $('.btn_jlnbsp').hide();
                    $('.btn_jlnbsh').hide();
                    $('.btn_jfsq').hide();
                    $('.btn_cfsq').hide();
                    $('.btn_jflq').hide();
                    $('.sc_image').hide();
                    $('.qr_uplaod').hide();
                    $('.pl_delete').hide();
                    $('.upImage').hide();
                    $('.btn_hzd').hide();
                    // $('.btn_kxjc').hide();
                    // $('.btn_jdjc').hide();
                    $('.upfj').hide();
                    $('.upseal').hide();
                    $('.addspjl').hide();
                    $('.tabUploadImageZf').hide();
                }
            }
        }
    }
});
function getImageWidth(url,maxWidth, maxHeight, callback) {
    // var img = new Image();
    // img.src = url;
    // // 如果图片被缓存，则直接返回缓存数据
    // if (img.complete) {
    //     callback(img.width, img.height);
    // } else {
    //     img.onload = function () {
    //         callback(img.width, img.height);
    //     }
    // }
    var image = new Image();
    //原图片原始地址（用于获取原图片的真实宽高，当<img>标签指定了宽、高时不受影响）
    image.src = url;
    // 用于设定图片的宽度和高度
    var tempWidth;
    var tempHeight;
    image.onload=function(){
        if (image.width > 0 && image.height > 0) {
            //原图片宽高比例 大于 指定的宽高比例，这就说明了原图片的宽度必然 > 高度
            if (image.width / image.height >= maxWidth / maxHeight) {
                if (image.width > maxWidth) {
                    tempWidth = maxWidth;
                    // 按原图片的比例进行缩放
                    tempHeight = (image.height * maxWidth) / image.width;
                } else {
                    // 按原图片的大小进行缩放
                    tempWidth = image.width;
                    tempHeight = image.height;
                }
            } else {// 原图片的高度必然 > 宽度
                if (image.height > maxHeight) {
                    tempHeight = maxHeight;
                    // 按原图片的比例进行缩放
                    tempWidth = (image.width * maxHeight) / image.height;
                } else {
                    // 按原图片的大小进行缩放
                    tempWidth = image.width;
                    tempHeight = image.height;
                }
            }

            callback(tempWidth, tempHeight);
            // 设置页面图片的宽和高
            // ImgObj.height = tempHeight;
            // ImgObj.width = tempWidth;
            // // 提示图片的原来大小
            // ImgObj.alt = image.width + "×" + image.height;
        }

    };
}
function zxkzfFrom(id){
    layerAjaxGet('/supervisor/projectManager/gerRecordHk?id='+id, '','', function (d) {
        $("#payLists").empty();
        for (var f = 0;f<d.supervisorProjectPayDTOS.length;f++){
            var str = "";
            var obj = d.supervisorProjectPayDTOS[f];
            str = "<div style='width: 45%;float: left'><label style=\"margin-top: 20px;float: left\">第"+obj.sppNo+"次付款</label>\n" +
                "                <div style=\"margin-top: 20px;float: left;width: 50%;margin-left: 2%\">\n";
            if(obj.sppNode == ""|| obj.sppNode == null){
                str +="                    <input type=\"text\"value=\""+obj.payDate+"\" style=\"background-color: #DCDDDC\"; required readonly=\"true\" class=\"layui-input\" disabled=\"disabled\">\n" +
                    "                </div>\n" +
                    "                <div style=\"margin-top: 20px;float: left;width: 20%;margin-left: 2%\">\n" +
                    "                    <input type=\"text\"value=\""+obj.sppPersent+"\" style=\"background-color: #DCDDDC\"; required readonly=\"true\" class=\"layui-input\" disabled=\"disabled\">\n" +
                    "                </div>" +
                    "</div>";
            }else{
                str +="                    <input type=\"text\"value=\""+obj.milepostName+"\"style=\"background-color: #DCDDDC;\"; required readonly=\"true\" class=\"layui-input\" disabled=\"disabled\">\n" +
                    "                </div>\n" +
                    "                <div style=\"margin-top: 20px;float: left;width: 20%;margin-left: 2%\">\n" +
                    "                    <input type=\"text\"value=\""+obj.sppPersent+"\"style=\"background-color: #DCDDDC;\"; required readonly=\"true\" class=\"layui-input\" disabled=\"disabled\">\n" +
                    "                </div>" +
                    "</div>";
            }

            $("#payLists").append(str);
        }
        $("#payId1").val(d.payId);
        $("#sppNo1").val(d.sppNo);
        if(d.sppNode == ""||d.sppNode == null){
            $("#sppNode1").val(d.payDate);
            $("#sppNode2").val("付款时间");
        }else{
            $("#sppNode1").val(d.badtName);
            $("#sppNode2").val("付款节点");
        }

        $("#sppPersent1").val(d.sppPersent);
        $("#zfMomney1").val(d.zfMoney);
        $("#fpMoney1").val(d.fpMoney);
        $("#createDate1").val(d.createDate);
        $("#isArrival").val(d.isArrival);
        var arrivalDate =  d.arrivalDate;
        var arrivalMoney = d.arrivalMoney;
        if(d.arrivalDate != ''&& d.arrivalDate != null){
            $("#jeDiv").empty();
            var dateArr = arrivalDate.split(",");
            var jeArr = arrivalMoney.split(",");
            var str = "";
            for(var x = 0;x<dateArr.length;x++){
                var date = dateArr[x];
                var je = jeArr[x];
                var _len = NumberToChinese(x+1);
                str +="<div class=\"layui-form-item\">\n" +
                    "                <div style=\"float: left;width: 100%\">\n" +
                    "                    <div style=\"width: 50%;float: left\">\n" +
                    "                        <label class=\"layui-form-label\" >第"+_len+"次到账时间</label>\n" +
                    "                        <div class=\"layui-input-block\" style=\"width: 190px;\">\n" +
                    "                            <input name=\"arrivalDate"+(x+1)+"\" class=\"fl\" op=\"0\" zgq=\"start\" type=\"datetime\" style=\"background-color: #DCDDDC;width: 96%;height: 36px\"\n" +
                    "                                   value = \""+date+"\"readonly = \"true\";id=\"arrivalDate"+(x+1)+"\"\n" +
                    "                                   AutoComplete=\"off\" placeholder=\"请选择时间\"/>\n" +
                    "                        </div>\n" +
                    "                    </div>\n" +
                    "                    <div style=\"width: 50%;float: left\">\n" +
                    "                        <label class=\"layui-form-label\" >第"+_len+"次到账金额</label>\n" +
                    "                        <div class=\"layui-input-inline\" style=\"width: 47%;float: left\">\n" +
                    "                            <input type=\"text\" name=\"arrivalMoney"+(x+1)+"\"AutoComplete=\"off\"\n" +
                    "                                   value = \""+je+"\"readonly = \"true\";placeholder=\"请填写到账金额\" id = \"arrivalMoney"+(x+1)+"\" required\n" +
                    "                                   lay-verify=\"required\" autocomplete=\"on\" class=\"layui-input fl\" style=\"background-color: #DCDDDC;width: 90%\"><span class='fl'>元<span>\n" +
                    "                        </div>\n" +
                    "                    </div>\n" +
                    "                </div>\n" +
                    "            </div>";
            }
            str+="<div class=\"layui-form-item\">\n" +
                "                <div style=\"float: left;width: 100%\">\n" +
                "                    <div style=\"width: 50%;float: left\">\n" +
                "                        <label class=\"layui-form-label\" >到账时间</label>\n" +
                "                        <div class=\"layui-input-block\" style=\"width: 47%;\">\n" +
                "                            <input name=\"arrivalDate"+(dateArr.length+1)+"\" class=\"fl gq\" op=\"0\" zgq=\"start\" type=\"datetime\" style=\"width: 96%;height: 36px\"\n" +
                "                                   id=\"arrivalDate"+(dateArr.length+1)+"\"\n" +
                "                                   AutoComplete=\"off\" placeholder=\"请选择时间\"/>\n" +
                "                        </div>\n" +
                "                    </div>\n" +
                "                    <div style=\"width: 50%;float: left\">\n" +
                "                        <label class=\"layui-form-label\" >到账金额</label>\n" +
                "                        <div class=\"layui-input-inline\" style=\"width: 47%;float: left\">\n" +
                "                            <input type=\"text\" name=\"arrivalMoney"+(dateArr.length+1)+"\"\n" +
                "                                   AutoComplete=\"off\" placeholder=\"请填写到账金额\" id = \"arrivalMoney"+(dateArr.length+1)+"\"\n" +
                "                                   required  lay-verify=\"required\" autocomplete=\"on\" class=\"layui-input fl\"style=\"width: 90%\"><span class='fl'>元<span>\n" +
                "                        </div>\n" +
                "                    </div>\n" +
                "                </div>\n" +
                "            </div>";
            $("#jeDiv").append(str);

        }
        lay('.gq').each(function () {
            laydate.render({
                elem: ".gq",
                type: 'date',
                trigger: 'click',
            });
        });
        layer.open({
            type:1,
            area:['65%','90%'],
            title: '工程款支付',
            content: $("#test"),
            shade: 0,
            btn: ['提交','关闭']
            ,btn1: function(index, layero){
                var data = {

                }

                data.payId = $("#payId1").val();//支付次数
                var _len = $("#jeDiv .layui-form-item").length;
                var arrivalMoney = $("#arrivalMoney"+_len).val();
                var arrivalDate = $("#arrivalDate"+_len).val();
                if(arrivalMoney == ''&& arrivalMoney == null){
                    layer.msg("请填写到账金额", {icon: 2});
                    return false;
                }
                var reg = /^[1-9][0-9]*([.][0-9]+)?$/;
                var flag = reg.test(arrivalMoney);
                if (!flag) {
                    layer.msg("请填写正确格式的金额", {icon: 2});
                    return false;
                }
                if(arrivalDate == ''&& arrivalDate == null){
                    layer.msg("请填写到账时间", {icon: 2});
                    return false;
                }
                data.arrivalMoney = arrivalMoney;
                data.arrivalDate = arrivalDate;
                layerAjax('/supervisor/projectManager/updateDz', data, '', function (d) {
                    if (d.flag == true) {
                        layer.closeAll();
                        _prom_page.events._init.hkRenderTable();
                    } else {
                        layer.msg(d.msg, {icon: 2});
                    }
                    console.log(d);
                });
            },
            btn2:function(index, layero){
                layer.closeAll();
            },
            cancel: function(layero,index){
                layer.closeAll();
            }

        });
        form.render();
    })
}
function jlkzfDel(str){
    layer.confirm("确定删除么", {
        btn: ['确定', '取消'] //按钮
    }, function () {
        // 按照逗号分隔
        var m = str.split(",");
        var id = m[0];
        var zfMoney = m[1];
        layerAjaxGet('/supervisor/projectManager/deletePay', {id: id,"xmId": jsondata.id,"zfMoney":zfMoney}, '', function (d) {
            if (d.flag) {
                console.log(id)
                console.log(zfMoney)
                var  jlzf= $("#jlzf").html();
                var jlmoney="";
                if(jlzf) {
                    jlmoney = parseFloat(jlzf) - parseFloat(zfMoney)
                }
                $("#jlzf").html(jlmoney);
                table.reload('huikuan');
                layer.closeAll();
                _prom_page.events._init.hkRenderTable();
            } else {
                layer.msg(d.msg, {icon: 2});
                layer.closeAll();
            }
        });
    })
    return false;
}
function openPay(){
    $("#zfcs").val(""); // 支付次数
    $("#jlPayMoney").val(""); // 支付金额
    $("#jlInvoiceMoney").val(""); // 发票金额
    layer.open({
        type:1,
        area:['40%','40%'],
        title: '监理费付款',
        content: $("#testPay"),
        shade: 0,
        btn: ['提交','关闭'],
        btnAlign: 'c'
        ,btn1: function(index, layero){
            var str = /^[0-9]+([.]{1}[0-9]{1,2})?$/;
            var zfcs = $("#zfcs").val();
            if(zfcs == ""|| zfcs == null || zfcs == undefined){
                layer.msg("请选择付费次数",{icon:2});
                return false;
            }
            var jlPayMoney = $("#jlPayMoney").val();
            if(jlPayMoney == ""|| jlPayMoney == null || jlPayMoney == undefined){
                layer.msg("请输入付款金额",{icon:2});
                return false;
            }else{
                if(!str.test(jlPayMoney)){
                    layer.msg("请输入正确金额格式",{icon:2});
                    return false;
                }
            }
            var jlInvoiceMoney = $("#jlInvoiceMoney").val();
            if(jlInvoiceMoney == ""|| jlInvoiceMoney == null || jlInvoiceMoney == undefined){
                layer.msg("请输入发票金额",{icon:2});
                return false;
            }else{
                if(!str.test(jlInvoiceMoney)){
                    layer.msg("请输入正确金额格式",{icon:2});
                    return false;
                }
            }
            // 请求后台校验支付金额、开票金额的总额需小于监理的合同额+补充协议金额
            layerAjaxGet('/supervisor/projectManager/verifyJINE', {id: jsondata.id,"jlPayMoney":jlPayMoney,"jlInvoiceMoney":jlInvoiceMoney}, '', function (d) {
                if (200 == d.code){
                    var json = {
                        sppId:zfcs,//支付表Id
                        projectId: jsondata.id,
                        zfMoney: jlPayMoney,
                        fpMoney:jlInvoiceMoney,
                        spmId: jsondata.spmId,
                        stageId: jsondata.stageId,
                        zfType:'2'
                    }
                    layerAjax('/supervisor/projectManager/savePayJL', json, '', function (d) {
                        if (d.flag == true) {
                            var  jlzf= $("#jlzf").html();
                            var jlmoney="";
                            if(jlzf){
                                jlmoney=parseFloat(jlzf)+parseFloat(json.zfMoney)
                            }else{
                                jlmoney=json.zfMoney;
                            }
                            $("#jlzf").html(jlmoney);
                            layer.msg("保存成功", {icon: 1});
                            layer.closeAll();
                            _prom_page.events._init.hkRenderTable();
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                        console.log(d);
                    });
                }else {
                    layer.msg(d.msg,{icon:2});
                    return false;
                }
            })
        },
        btn2:function(index, layero){
            layer.closeAll();
        },
        cancel: function(layero,index){
            layer.closeAll();
        }

    });
}
var chnNumChar = ["零","一","二","三","四","五","六","七","八","九"];
var chnUnitSection = ["","万","亿","万亿","亿亿"];
var chnUnitChar = ["","十","百","千"];
function SectionToChinese(section){
    var strIns = '', chnStr = '';
    var unitPos = 0;
    var zero = true;
    while(section > 0){
        var v = section % 10;
        if(v === 0){
            if(!zero){
                zero = true;
                chnStr = chnNumChar[v] + chnStr;
            }
        }else{
            zero = false;
            strIns = chnNumChar[v];
            strIns += chnUnitChar[unitPos];
            chnStr = strIns + chnStr;
        }
        unitPos++;
        section = Math.floor(section / 10);
    }
    return chnStr;
}
function NumberToChinese(num){
    var unitPos = 0;
    var strIns = '', chnStr = '';
    var needZero = false;
    if(num === 0){
        return chnNumChar[0];
    }
    while(num > 0){
        var section = num % 10000;
        if(needZero){
            chnStr = chnNumChar[0] + chnStr;
        }
        strIns = SectionToChinese(section);
        strIns += (section !== 0) ? chnUnitSection[unitPos] : chnUnitSection[0];
        chnStr = strIns + chnStr;
        needZero = (section < 1000) && (section > 0);
        num = Math.floor(num / 10000);
        unitPos++;
    }
    return chnStr;
}



